1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
//! # 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}; //! # use 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 //! # } //! # } //! //! #[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 has `io` and //! `time` drivers already enabled. //! * `#[runtime(io)]`: enable the `io` driver; //! * `#[runtime(time)]`: enable the `time` driver; //! * `#[runtime(skip)]`: ignore the field. //! //! [examples]: https://github.com/primetype/organix/tree/master/examples //! [`Watchdog`]: ./struct.WatchdogMonitor.html pub mod runtime; pub mod service; mod watchdog; pub use organix_derive::{IntercomMsg, Organix}; pub use service::{Service, ServiceIdentifier, ServiceManager, ServiceState}; pub use watchdog::{Organix, WatchdogBuilder, WatchdogError, WatchdogMonitor, WatchdogQuery};