kompact 0.9.0

Kompact is a Rust implementation of the Kompics component model combined with the Actor model.
Documentation

The Kompact message-passing framework provides a hybrid approach between the Kompics component model and the Actor model for writing distributed systems.

To get all Kompact related things into scope import use kompact::prelude::*; instead of use kompact::*;.

Hello World Example

use kompact::prelude::*;

#[derive(ComponentDefinition, Actor)]
struct HelloWorldComponent {
ctx: ComponentContext<Self>
}
impl HelloWorldComponent {
pub fn new() -> HelloWorldComponent {
HelloWorldComponent {
ctx: ComponentContext::new()
}
}
}
impl Provide<ControlPort> for HelloWorldComponent {
fn handle(&mut self, event: ControlEvent) -> () {
match event {
ControlEvent::Start => {
info!(self.ctx.log(), "Hello World!");
self.ctx().system().shutdown_async();
}
_ => (), // ignore other control events
}
}
}

let system = KompactConfig::default().build().expect("system");
let component = system.create(HelloWorldComponent::new);
system.start(&component);
system.await_termination();