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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
// #![warn(missing_docs)]
#![warn(rust_2018_idioms)]
#![warn(unreachable_pub)]
pub mod proto {
//! Protocols. Actors interact by communication.
/// A trait showing that the type implementing it can be sent between the
/// actors.
pub use mm1_proto::Message;
/// A proc-macro attribute to make a message out of a type.
///
/// Example:
/// ```rust
/// #[message]
/// struct Accept {
/// reply_to: Address,
/// timeout: Duration,
/// }
///
/// #[message]
/// struct Accepted {
/// io: Unique<TcpStream>,
/// }
/// ```
pub use mm1_proto::message;
/// The low-level API-to the actor system.
/// See [`Call`](crate::core::context::Call).
pub use mm1_proto_system as system;
}
pub mod address {
//! Addresses, masks, subnets.
//!
//! Addresses in `mm1` are used as destinations to send messages to.
//! A type `Address` is represented as a `u64` integer, and is very similar
//! to IPv4- or IPv6-address, in that the whole space of addresses may be
//! split into sub-spaces using netmasks.
//!
//! > Example:
//! >
//! > A subnet `aabbccddee000000/40` contains 2^24 addresses: from
//! > `aabbccddee000000` to `aabbccddeeFFFFFF`.
//!
//! The way addresses are written takes page from IPv6's notation: the
//! leftmost longest series of consequent zero hex-digits is replaced with a
//! `':'`-sign. To improve readability, the address is surrounded by
//! corner brackets.
//!
//! The reasons to choose corner brackets:
//! - so that they don't mix visually with IPv6-addresses.
//! - so that they do not require additional quotes when used in YAML.
//! - so that the addresses remind us a little bit of Erlang PIDs :).
//!
//! > Example:
//! > - `aabbccddee000000/40` shall be written as `<aabbccddee:>/40`.
//! > - `ffff000000084b03/64` shall be written as `<ffff:84b03>/64`.
//!
//! Actors' implementations should treat addresses as opaque types
//! (implementing `Message`, `Copy`, `Eq`, `Cmp`, and `Hash`).
//!
//! The nature of addresses should serve the convenience of the operators,
//! and probably ease up the implementation of the multi-node messaging.
//!
//! So, the default value for the node's subnet is `<ffff:>/16`. This
//! probably should be treated as `127.0.0.0/8` in IPv4.
/// Address — a destination to send messages to.
pub use mm1_address::address::Address;
pub use mm1_address::address::AddressParseError;
pub use mm1_address::pool::{
Lease as AddressLease, LeaseError as AddressLeaseError, Pool as AddressPool,
};
/// Address of a network, i.e. an `Address` in combination with a `NetMask`.
pub use mm1_address::subnet::NetAddress;
/// Mask — specifies how many leading bits in the address are fixed.
pub use mm1_address::subnet::NetMask;
pub use mm1_address::subnet::{InvalidMask, MaskParseError, NetAddressParseError};
}
pub mod common {
/// A helper to define an error-kind enum
pub use mm1_common::impl_error_kind;
/// An empty type, i.e. no instance of that type can be produced.
pub use mm1_common::types::Never;
pub mod log {
pub use mm1_common::log::*;
}
pub mod error {
pub use mm1_common::errors::chain::*;
pub use mm1_common::errors::error_kind::HasErrorKind;
pub use mm1_common::errors::error_of::ErrorOf;
pub use mm1_common::types::{AnyError, StdError};
}
pub mod future {
pub use mm1_common::futures::catch_panic::{CatchPanic, CatchPanicExt};
pub use mm1_common::futures::timeout::FutureTimeoutExt;
}
pub mod serde {
pub use mm1_common::serde::*;
}
}
pub mod core {
//! The API to implement actors.
pub use mm1_core::{tap, tracing};
pub mod envelope {
//! An [`Envelope`] is a type-erasing container for the sent messages.
/// A type-erasing container for the message that has been sent.
pub use mm1_core::envelope::Envelope;
/// An opaque type containing some information about the message that
/// has been sent.
pub use mm1_core::envelope::EnvelopeHeader;
/// A macro helping to match an [`Envelope`].
pub use mm1_core::envelope::dispatch;
/// A type-erasing container for the message.
pub use mm1_core::message::AnyMessage;
}
pub mod context {
//! Actor's behaviour is defined as an async-function that receives an
//! exclusive reference to some *context* as its first argument.
//! The concrete type of the *context* is supposed to remain unknown to
//! the actors: they are to interact with their *contexts* via a set of
//! traits, that are defined on a *context*.
/// Report the completion of the init-phase.
pub use mm1_core::context::InitDone;
/// Link to/unlink from other actors.
pub use mm1_core::context::Linking;
/// Provides a current Instant.
pub use mm1_core::context::Now;
/// Terminate its own execution.
pub use mm1_core::context::Quit;
/// Start other actors.
pub use mm1_core::context::Start;
/// A convenience trait to simply send a message to another actor.
pub use mm1_core::context::Tell;
/// Watch/unwatch the termination of other actors.
pub use mm1_core::context::Watching;
/// Create another context (probably of a different kind), having
/// "bound" to the required address. The exact type of address,
/// and the concept of "bind" are (intentionally) defined a bit loosely.
/// Examples:
/// - `Bind<NetAddress>` — would most likely mean catch all the messages
/// sent to any address within the specified network;
/// - `Bind<TypeId>` — handle the requests of certain kind.
pub use mm1_core::context::{Bind, BindArgs, BindErrorKind};
/// Create another context, having an address distinct from the original
/// context's one.
pub use mm1_core::context::{Fork, ForkErrorKind};
/// Send and receive messages.
pub use mm1_core::context::{Messaging, RecvErrorKind, SendErrorKind};
/// Ping the specified actor.
pub use mm1_core::context::{Ping, PingErrorKind};
/// Stop other actors.
pub use mm1_core::context::{ShutdownErrorKind, Stop};
}
}
#[cfg(feature = "ask")]
pub mod ask {
pub use mm1_ask::{Ask, AskErrorKind, Reply};
pub mod proto {
pub type RequestHeader = mm1_proto_ask::RequestHeader;
pub type Request<Rq> = mm1_proto_ask::Request<Rq>;
#[doc(hidden)]
pub type ResponseHeader = mm1_proto_ask::ResponseHeader;
#[doc(hidden)]
pub type Response<Rs> = mm1_proto_ask::Response<Rs>;
}
}
#[cfg(feature = "server")]
pub mod server {
//! Server — a standard way to implement a long-living actor that handles
//! inbound messages.
/// create a new server builder
pub use mm1_server::new;
pub mod behaviour {
/// Handle inbound messages.
pub use mm1_server::OnMessage;
/// Handle inbound requests (see `mm1::ask`).
pub use mm1_server::OnRequest;
/// Result of handling a message/request.
pub use mm1_server::Outcome;
}
}
#[cfg(feature = "sup")]
pub mod sup {
//! Supervisors — the actors that manage other actors.
#[cfg(feature = "sup")]
/// The protocol to communicate with supervisors.
pub use mm1_proto_sup as proto;
pub mod common {
//! The building blocks shared across different types of supervisors.
/// A recipe for a child-actor.
pub use mm1_sup::common::child_spec::ChildSpec;
pub use mm1_sup::common::child_spec::InitType;
pub use mm1_sup::common::factory::ActorFactory;
/// Multiple-use actor factory.
pub use mm1_sup::common::factory::ActorFactoryMut;
/// Single-use actor-factory.
pub use mm1_sup::common::factory::ActorFactoryOnce;
pub type RestartIntensity = mm1_sup::common::restart_intensity::RestartIntensity;
pub use mm1_sup::common::restart_intensity::MaxRestartIntensityReached;
}
pub mod uniform {
//! Uniform supervisor — the actor, that supervises the children of the
//! same type.
/// The recipe for a supervisor.
pub use mm1_sup::uniform::UniformSup;
/// Blanket trait for contexts suitable for running a
/// uniform-supervisor.
pub use mm1_sup::uniform::UniformSupContext;
/// types of a child of a uniform-supervisor.
pub use mm1_sup::uniform::child_type;
/// The behaviour function of the uniform supervisor actor.
pub use mm1_sup::uniform::uniform_sup;
}
pub mod mixed {
//! Mixed supervisor — the actor, that supervises the children of
//! different types.
/// Type of the child: `Permanent` | `Temporary`.
pub use mm1_sup::mixed::ChildType;
/// The recipe for a supervisor.
pub use mm1_sup::mixed::MixedSup;
/// Blanket trait for contexts suitable for running a mixed-supervisor.
pub use mm1_sup::mixed::MixedSupContext;
/// Mixed supervisor's failure type.
pub use mm1_sup::mixed::MixedSupError;
/// The behaviour function of the mixed supervisor actor.
pub use mm1_sup::mixed::mixed_sup;
/// module with supervision strategies.
pub use mm1_sup::mixed::strategy;
}
}
#[cfg(feature = "runtime")]
pub mod runtime {
pub use mm1_node::config;
pub use mm1_node::runtime::{Local, Rt};
}
pub use mm1_runnable as runnable;
#[cfg(feature = "timer")]
pub mod timer {
pub use mm1_timer::v1;
}
#[cfg(feature = "multinode")]
pub mod multinode {
pub mod proto {
pub use mm1_proto_network_management::protocols::{
RegisterProtocolRequest, RegisterProtocolResponse,
};
}
#[doc(hidden)]
pub mod system_proto {
pub use mm1_multinode::proto::*;
}
pub use mm1_multinode::codec::Protocol;
pub use mm1_proto_well_known::MULTINODE_MANAGER;
}
// #[cfg(feature = "multinode")]
// pub mod message_codec {
// pub use mm1_multinode::codecs::Codec;
// }
#[cfg(feature = "test-util")]
pub mod test {
pub use mm1_test_rt::rt;
}