[−][src]Crate organix
Organix, organic application
Organix
provides an opinionated way to build application with
multiple services independent from each other but still require
communication channels.
With Organix
it is possible to design the different components
of your application in isolation from each others. It allows to
build runtimes for your applications.
Minimal configuration
The core component of Organix
is the Watchdog
. In order to
build the Watchdog
you need to define an Organix
object
which defines your app and its services.
use organix::{Organix, WatchdogBuilder}; #[derive(Organix)] struct App; let watchdog = WatchdogBuilder::<App>::new().build();
defining a service
Now defining a new service:
use organix::{Organix, IntercomMsg, ServiceState, Service, ServiceIdentifier, service}; use async_trait::async_trait; struct HeartBeat(ServiceState<Self>); #[async_trait] impl Service for HeartBeat { const SERVICE_IDENTIFIER: ServiceIdentifier = "heart-beat"; type IntercomMsg = service::NoIntercom; fn prepare(state: ServiceState<Self>) -> Self { // initialize the state of the service Self(state) } async fn start(mut self) { // where you do the work } }
Now from there you can start the service by adding it in the App
:
use organix::{Organix, ServiceManager}; #[derive(Organix)] struct App { heart_beat: service::ServiceManager<HeartBeat>, }
See the examples for more complete details on how to build services with the provided interface.
Configuring the runtime
It is possible to configure the runtime of the different serviced.
on the Organix
app type
#[runtime(shared)]
: will make all the services to use a shared runtime by default. Otherwise the default is for every service to run an individual runtime.
On the field of the Organix
app type
#[runtime(shared)]
: will make the associated service to use a shared runtime with the other shared labeled services. This shared runtime hasio
andtime
drivers already enabled.#[runtime(io)]
: enable theio
driver;#[runtime(time)]
: enable thetime
driver;#[runtime(skip)]
: ignore the field.
Re-exports
pub use service::Service; |
pub use service::ServiceIdentifier; |
pub use service::ServiceManager; |
pub use service::ServiceState; |
Modules
runtime | |
service |
Structs
WatchdogBuilder | |
WatchdogMonitor | |
WatchdogQuery | special access to the watchdog direct handle |
Enums
WatchdogError |
Traits
Organix | trait to define the different core services and their associated metadata |
Derive Macros
IntercomMsg | |
Organix |