From 02bb93f958786955e2d5f9057975724868bf0818 Mon Sep 17 00:00:00 2001 From: Mahmut Bulut Date: Sun, 29 Sep 2019 15:17:01 +0200 Subject: [PATCH] Root spawn doc --- src/bastion.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/bastion.rs b/src/bastion.rs index 044ebd17..05bc6705 100644 --- a/src/bastion.rs +++ b/src/bastion.rs @@ -111,6 +111,34 @@ impl Bastion { } /// + /// Supervisor builder for the runtime. + /// + /// # Arguments + /// * `name` - Supervisor name + /// * `system` - Supervisor system's name for grouping + /// multiple supervisor's to the same system. + /// + /// After building the supervisor it will be placed under the supervision tree. + /// + /// When runtime is started, supervision tree will be traversed back again + /// to start supervisors and their children. + /// + /// Supervisors work exactly like self-contained actor systems. + /// One addition over ordinary actor system is that, + /// these supervisors also can communicate with each other with async messages. + /// + /// # Example + /// + /// ```rust + ///# use bastion::prelude::*; + ///# use std::{fs, thread}; + ///# + ///# fn main() { + ///# Bastion::platform(); + ///Bastion::supervisor("background-worker", "fetcher-system") + /// .strategy(SupervisionStrategy::OneForAll); + ///# } + /// ``` pub fn supervisor(name: &'static str, system: &'static str) -> Supervisor { let sp = Supervisor::default().props(name.into(), system.into()); Bastion::traverse(sp)