-
Notifications
You must be signed in to change notification settings - Fork 22
/
stream.rs
38 lines (30 loc) · 964 Bytes
/
stream.rs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
use elfo::{config::AnyConfig, prelude::*, stream::Stream};
use futures::stream;
#[message]
struct SomeMessage(u32);
#[message]
struct EndOfMessages;
fn samples() -> Blueprint {
ActorGroup::new().exec(|mut ctx| async move {
let stream = Stream::from_futures03(stream::iter(vec![SomeMessage(0), SomeMessage(1)]));
ctx.attach(stream);
while let Some(_envelope) = ctx.recv().await {
// ...
}
})
}
#[tokio::main]
async fn main() {
let topology = elfo::Topology::empty();
let logger = elfo::batteries::logger::init();
let samples = topology.local("samples");
let loggers = topology.local("loggers");
let configurers = topology.local("system.configurers").entrypoint();
samples.mount(self::samples());
loggers.mount(logger);
configurers.mount(elfo::batteries::configurer::fixture(
&topology,
AnyConfig::default(),
));
elfo::init::start(topology).await;
}