use std::time::Duration;
#[test]
fn agent_quickstart_example() {
use datum::prelude::*;
use datum_agent::{Agent, JobMat, JobSpec};
let agent = Agent::start().expect("agent starts");
let registry = agent.registry();
let spec = JobSpec::new("tick-counter", |context| {
let control = context.control();
Ok(
Source::tick(Duration::ZERO, Duration::from_millis(10), 1_u64)
.instrumented(
format!("{}:{}", context.name(), context.generation()),
context.instrumentation_registry(),
)
.via_mat(context.drain_flow(), Keep::right)
.to_mat(Sink::ignore(), move |_switch, completion| {
JobMat::new(completion, control.clone())
}),
)
});
registry.submit(spec).expect("job submitted");
registry.start("tick-counter").expect("job started");
let status = registry.status("tick-counter").expect("status");
assert_eq!(status.name, "tick-counter");
registry.drain("tick-counter").expect("drain requested");
registry.shutdown().expect("agent shuts down");
}