1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2020 Google LLC
//
// Use of this source code is governed by an MIT-style license that can be found
// in the LICENSE file or at https://opensource.org/licenses/MIT.

use std::time::Duration;

use fleetspeak::Message;

fn main() {
    fleetspeak::startup("0.0.1");

    loop {
        let packet = fleetspeak::receive_with_heartbeat(Duration::from_secs(1));

        let request = std::str::from_utf8(&packet.data).unwrap();
        let response = format!("Hello, {}!", request);

        fleetspeak::send(Message {
            service: String::from("greeter"),
            kind: None,
            data: response.into_bytes(),
        });
    }
}