Module reactive_messaging::prelude
source · Expand description
Re-exports of types useful for users of this crate
Re-exports
pub use crate::ron_serializer;pub use crate::ron_deserializer;pub use crate::ReactiveMessagingSerializer;
Macros
- Macro to close, atomically-ish, all Multis passed in as parameters
- Instantiates & allocates resources for a GenericSocketClient, ready to be later started by spawn_unresponsive_client_processor!() or spawn_responsive_client_processor!().
Params: - Instantiates & allocates resources for a GenericSocketServer, ready to be later started by spawn_unresponsive_server_processor!() or spawn_responsive_server_processor!().
Params: - Macro to close, atomically-ish, all Unis passed as parameters
Structs
- Implements something that could be called the “Zero-Cost Const Configuration Pattern”, that produces a
usizewhose goal is to be the only const parameter of a generic struct (avoiding the alternative of bloating it with several const params).
When using the const “query functions” defined here inifs, the compiler will have the opportunity to cancel out any unreachable code (zero-cost abstraction).
Some commonly used combinations may be pre-defined in some enum variants, but you may always build unmapped possibilities through [Self::custom()].
Usage examples: - Real definition & implementation for our Socket Client, full of generic parameters.
Probably you want to instantiate this structure through the sugared macro new_socket_client!() instead. Generic Parameters: - Real definition & implementation for our Socket Server, full of generic parameters.
Probably you want to instantiate this structure through the sugared macro new_socket_server!() instead. Generic Parameters: Multiis an event handler capable of having several “listeners” – all of which receives all events.
With this struct, it is possible to:- Special
Streamimplementation to avoid using dynamic dispatching, so to allow the compiler to fully optimize the whole event consumption chain.
The following paths are covered: - Wrapper type for data providing an atomic reference counter for dropping control, similar to
Arc, but allowing a custom allocator to be used – OgreAllocator. providing reference counting similar to Arc - Wrapper type for data that requires a custom Drop to be called (through an OgreAllocator). Similar to C++’s
unique_ptr - Represents a reactive channel connected to a remote peer, through which we’re able to send out “local messages” of type
RetryableSenderImpl::LocalMessages.
the Self::send() method honors whatever retrying config is specified in [RetryableSenderImpl::CONST_CONFIG]. IMPLEMENTATION NOTE: GAT traits (to reduce the number of generic parameters) couldn’t be used here – even after applying this compiler bug workaround https://github.com/rust-lang/rust/issues/102211#issuecomment-1513931928 – the “error: implementation ofstd::marker::Sendis not general enough” bug kept on popping up in user provided closures that called other async functions. - Socket options for the local peer to be set when the connection is stablished
- Contains the producer-side Uni handle used to interact with the
unievent – for closing the stream, requiring stats, …
Enums
- Specifies the channels (queues) from
reactive-mutinythay may be used to send/receive data.
On different hardware, the performance characteristics may vary. - The internal events a reactive processor (for a server or client) shares with the user code.
The user code may use those events to maintain a list of connected clients, be notified of stop/close/quit requests, init/de-init sessions, etc. Note that thePeerobjects received in those events may be used, at any time, to send messages to the clients – like “Shutting down. Goodbye”. IMPLEMENTATION NOTE: GAT traits (to reduce the number of generic parameters) couldn’t be used here – even after applying this compiler bug workaround https://github.com/rust-lang/rust/issues/102211#issuecomment-1513931928 – the “error: implementation ofstd::marker::Sendis not general enough” bug kept on popping up in user provided closures that called other async functions. - Honors the Zero-Cost Instrumentation Pattern for the [stream_executors]:
Designed to be used as a const generic parameter for Structs, causes the conditional instrumentation code in client structs to be selectively compiled – see the implemented const methods for documentation of each available instrument. - Specifies how to behave when communication failures happen
- Represents a client built out of
CONFIG(au64version of [ConstConfig], from which the other const generic parameters derive).
Don’t instantiate this struct directly – use new_socket_client!() instead. - Represents a server built out of
CONFIG(au64version of [ConstConfig], from which the other const generic parameters derive).
Don’t instantiate this struct directly – use new_socket_server!() instead.
Traits
- Defines common abstractions on how [Uni]s receives produced events and delivers them to
Streams.
Implementors should also implement one of ChannelProducer or [UniZeroCopyChannel]. NOTE: all async functions are out of the hot path, so theasync_traitwon’t impose performance penalties - Source of events for MutinyStream.
- Defines abstractions specific to [Uni] channels
- Defines how to send events (to a [Uni] or [Multi]).
- Defines abstractions specific to [Uni] channels
- A fully fledged
Multichannel, that has both the producer and consumer parts Also, laverages generic programming by allowing simpler generic parameters: - Defines a fully fledged
Unichannel, that has both the producer and consumer parts Also, laverages generic programming by allowing simpler generic parameters: - This trait exists to allow simplifying generic declarations of concrete Multi types. See also [GenericUni].
Usage: - This trait exists to allow simplifying generic declarations of concrete Uni types. See also [GenericMulti].
Usage: - Dictates how data slots should be acquired and returned for future reuse.
Two APIs are available: - Adherents will, typically, also implement [ReactiveMessagingUnresponsiveSerializer].
By upgrading your type with this trait, it is possible to build a “Responsive Processor”, where the returnedStreamcontains the messages to be sent as an answer to the remote peer.
This trait, therefore, specifies (to the internal sender) how to handle special response cases, like “no answer” and “disconnection” messages.
Type Aliases
- Concrete type of the
Streams this crate produces.
Type for theStreamwe create when reading from the remote peer.
This type is intended to be used only for the first level ofdialog_processor_builder()s you pass to the [SocketClient] or [SocketServer], as Rust Generics isn’t able to infer a genericStreamtype in this situation (in which theStreamis created inside the generic function itself).
If your logic uses functions that receiveStreams, you’ll want flexibility to do whatever you want with theStream(which would no longer be aMutinyStream), so declare such functions as: - Default
Multifor those who wants to useArcas the wrapping type for payloads - Default
Multifor those who want the more performant OgreArc as the wrapping type for their payloads - Default
UniBuilderfor “moving” data around – good for small payloads (< 1k) whose types don’t require a customDropfunction - Default ‘UniBuilder’ for “zero-copying” data that will either be shared around or has a reasonably “big” payload (> 1k)