hello/
hello.rs

1// Copyright 2020 Google LLC
2//
3// Use of this source code is governed by an MIT-style license that can be found
4// in the LICENSE file or at https://opensource.org/licenses/MIT.
5
6use std::time::Duration;
7
8use fleetspeak::Message;
9
10fn main() {
11    fleetspeak::startup("0.0.1");
12
13    loop {
14        let packet = fleetspeak::receive_with_heartbeat(Duration::from_secs(1));
15
16        let request = std::str::from_utf8(&packet.data).unwrap();
17        let response = format!("Hello, {}!", request);
18
19        fleetspeak::send(Message {
20            service: String::from("greeter"),
21            kind: None,
22            data: response.into_bytes(),
23        });
24    }
25}