kompact 0.10.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::uninitialised()
}
}
}
impl ComponentLifecycle for HelloWorldComponent {
fn on_start(&mut self) -> Handled {
info!(self.ctx.log(), "Hello World!");
self.ctx().system().shutdown_async();
Handled::Ok
}
}

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

Crate Feature Flags

The following crate feature flags are available. They are configured in your Cargo.toml.

  • silent_logging
  • Reduces logging to INFO in debug builds and ERROR in release builds
  • Must be used with --no-default-features
  • low_latency
  • Prevents thread pool threads from going to sleep when using the default pool.
  • This can improve reaction time to incoming network events, at the cost of much higher CPU utilisation.
  • ser_id_64 (default), ser_id_32, ser_id_16, ser_id_8
  • Selects the bit-width of serialisation identifiers.
  • Trying to use a serialisation id that is too large for the selected width will result in a compile-time error.
  • All values are mutually exclusive and all but the default of ser_id_64 must be used with --no-default-features.
  • thread_pinning
  • Enables support for pinning pool threads to CPU cores (or rather processing units).
  • This flag has no effect if the runtime OS does not support thread pinning.
  • Enabling this will cause as many threads as there are PUs to be pinned by default.
  • Assignments can be customised by providing a custom scheduler with the desired settings.
  • See executors crate for more details.
  • serde_support (default)
  • Build with support for Serde serialisers.
  • type_erasure (nightly-only)
  • Build with an experimental API for dyn type-erased components.
  • use_local_executor (default)
  • Use thread-local executors to avoid cloning the handle to the system scheduler for every component scheduling.
  • Not all scheduler implementations support this feature, so you might have to disable it via --no-default-features if you are using a custom scheduler.
  • implicit_routes (default)
  • Allow default broadcast and select actor paths on any node in the tree, not just where explicitly set via set_routing_policy.
  • While this feature is convenient, it may open up your system to DoS attacks via broadcast on high-level nodes (e.g. tcp://1.2.3.4:8000/*).
  • If you are concered about this security risk, you can disable this feature by using --no-default-features.