[−][src]Crate kompact
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();
Re-exports
pub use executors; |
Modules
component | Traits and structs for component API and internals |
default_components | Default implementations for system components |
doctest_helpers | Helper structs and functions for doctests. |
messaging | Facilities and utilities for dealing with network messages Messaging types for sending and receiving messages between remote actors. |
net | Default networking implementation |
prelude | To get all kompact related things into scope import as |
prelude_test | A module containing helper functions for (unit) testing |
runtime | Kompact system runtime facilities, such as configuration and schedulers |
serde_serialisers | Provides serialisation support for Serde |
timer | Reusable timer facility internals |
Macros
ignore_control | A macro that provides an empty implementation of the ControlPort handler. |
ignore_indications | A macro that provides an empty implementation of the required handler for the given |
ignore_requests | A macro that provides an empty implementation of the provided handler for the given |
match_deser | A macro to make matching serialisation ids and deserialising easier |
Type Definitions
KompactLogger | A simple type alias Kompact's slog |
Never | A more readable placeholder for a stable Never ( |