[go: up one dir, main page]

bastion/
lib.rs

1//! # Bastion: Fault-tolerant Runtime for Rust applications
2//!
3//! Bastion is a highly-available, fault-tolerant runtime system
4//! with dynamic dispatch oriented lightweight process model.
5//! It supplies actor model like concurrency with primitives
6//! called [lightproc] and utilize all the system resources
7//! efficiently with at-most-once message delivery guarantee.
8//!
9//! To have a quick start please head to: [Bastion System Documentation](struct.Bastion.html).
10//!
11//! ## Features
12//! * Message-based communication makes this project a lean mesh of actor system.
13//!     * Without web servers, weird shenanigans, forced trait implementations, and static dispatch.
14//! * Runtime fault-tolerance makes it a good candidate for distributed systems.
15//!     * If you want the smell of Erlang and the powerful aspects of Rust. That's it!
16//! * Completely asynchronous runtime with NUMA-aware and cache-affine SMP executor.
17//!     * Exploiting hardware locality wherever it is possible. It is designed for servers.
18//! * Supervision system makes it easy to manage lifecycles.
19//!     * Kill your application in certain condition or restart you subprocesses whenever a certain condition is met.
20//! * Automatic member discovery, cluster formation and custom message passing between cluster members.
21//!     * Using zeroconf or not, launch your bastion cluster from everywhere, with a single actor block.
22//! * Proactive IO system which doesn't depend on anything other than `futures`.
23//!     * Bastion's proactive IO has scatter/gather operations, `io_uring` support and much more...
24//!
25//! ## Guarantees
26//! * At most once delivery for all the messages.
27//! * Completely asynchronous system design.
28//! * Asynchronous program boundaries with [fort].
29//! * Dynamic supervision of supervisors (adding a subtree later during the execution)
30//! * Lifecycle management both at `futures` and `lightproc` layers.
31//! * Faster middleware development.
32//! * Above all "fault-tolerance".
33//!
34//! ## Why Bastion?
35//! If one of the questions below is answered with yes, then Bastion is just for you:
36//! * Do I want proactive IO?
37//! * Do I need fault-tolerance in my project?
38//! * Do I need to write resilient middleware/s?
39//! * I shouldn't need a webserver to run an actor system, right?
40//! * Do I want to make my existing code unbreakable?
41//! * Do I need an executor which is using system resources efficiently?
42//! * Do I have some trust issues with orchestration systems?
43//! * Do I want to implement my own application lifecycle?
44//!
45//!
46//! [lightproc]: https://docs.rs/lightproc/
47//! [fort]: https://docs.rs/fort/
48//!
49
50#![doc(
51    html_logo_url = "https://raw.githubusercontent.com/bastion-rs/bastion/master/img/bastion-logo.png"
52)]
53// Force missing implementations
54#![warn(missing_docs)]
55#![warn(missing_debug_implementations)]
56// Deny using unsafe code
57#![deny(unsafe_code)]
58// Doc generation experimental features
59#![cfg_attr(feature = "docs", feature(doc_cfg))]
60
61pub use self::bastion::Bastion;
62pub use self::callbacks::Callbacks;
63pub use self::config::Config;
64
65#[macro_use]
66mod macros;
67
68mod bastion;
69mod broadcast;
70mod callbacks;
71mod child;
72mod config;
73mod system;
74
75pub mod child_ref;
76pub mod children;
77pub mod children_ref;
78pub mod context;
79pub mod dispatcher;
80pub mod envelope;
81pub mod executor;
82#[cfg(not(target_os = "windows"))]
83pub mod io;
84pub mod message;
85pub mod path;
86#[cfg(feature = "scaling")]
87pub mod resizer;
88pub mod supervisor;
89
90pub mod errors;
91
92pub mod distributor;
93
94distributed_api! {
95    // pub mod dist_messages;
96    pub mod distributed;
97}
98
99///
100/// Prelude of Bastion
101pub mod prelude {
102    pub use crate::bastion::Bastion;
103    pub use crate::callbacks::Callbacks;
104    pub use crate::child_ref::ChildRef;
105    pub use crate::children::Children;
106    pub use crate::children_ref::ChildrenRef;
107    pub use crate::config::Config;
108    pub use crate::context::{BastionContext, BastionId, NIL_ID};
109    pub use crate::dispatcher::{
110        BroadcastTarget, DefaultDispatcherHandler, Dispatcher, DispatcherHandler, DispatcherMap,
111        DispatcherType, NotificationType,
112    };
113    pub use crate::distributor::Distributor;
114    pub use crate::envelope::{RefAddr, SignedMessage};
115    pub use crate::errors::*;
116    #[cfg(not(target_os = "windows"))]
117    pub use crate::io::*;
118    pub use crate::message::{Answer, AnswerSender, Message, MessageHandler, Msg};
119    pub use crate::msg;
120    pub use crate::path::{BastionPath, BastionPathElement};
121    #[cfg(feature = "scaling")]
122    pub use crate::resizer::{OptimalSizeExploringResizer, UpperBound, UpscaleStrategy};
123    pub use crate::supervisor::{
124        ActorRestartStrategy, RestartPolicy, RestartStrategy, SupervisionStrategy, Supervisor,
125        SupervisorRef,
126    };
127    pub use crate::{answer, blocking, children, run, spawn, supervisor};
128
129    distributed_api! {
130        // pub use crate::dist_messages::*;
131        pub use crate::distributed::*;
132        pub use artillery_core::cluster::ap::*;
133        pub use artillery_core::epidemic::prelude::*;
134    }
135}