Expand description
Foundational system components for Relay’s services.
Relay’s system is based on [tokio]. To use any of these components, ensure a tokio runtime is
available.
§Services
The basic building block in Relay are asynchronous Services. Each service implements an
Interface, which consists of one or many messages that can be sent to the service using its
Addr. See the docs of these types for more information on how to implement and use them.
§Shutdown
The static Controller service can listen for process signals and initiate a graceful
shutdown. Note that services must check a ShutdownHandle to receive these signals. See the
struct level documentation for more information.
Macros§
Structs§
- Addr
- The address of a
Service. - Async
Response - Message response resulting in an asynchronous
Request. - Broadcast
Channel - A channel that broadcasts values to attached senders.
- Broadcast
Request - The request when sending an asynchronous message to a service.
- Broadcast
Response - Variation of
AsyncResponsethat efficiently broadcasts responses to many requests. - Broadcast
Sender - Sends a message response from a service back to the waiting
BroadcastRequest. - Builder
- Configures a Relay
Runtime. - Controller
- Service to start and gracefully stop the system runtime.
- Handle
- Handle to the
Runtime. - Monitored
Future - A future that tracks metrics.
- NoResponse
- Message response for fire-and-forget messages with no output.
- RawMetrics
- The raw metrics extracted from a
MonitoredFuture. - Receiver
- Inbound channel for messages sent through an
Addr. - Recipient
- An address to a
Serviceimplementing any interface that takes a given message. - Request
- The request when sending an asynchronous message to a service.
- Runtime
- A Relay async runtime.
- Runtime
Metrics - Handle to the
Runtime’s metrics. - Send
Error - An error when sending a message to a service fails.
- Sender
- Sends a message response from a service back to the waiting
Request. - Service
Error - The service failed.
- Service
Id - A per runtime unique identifier for a started service.
- Service
Join Handle - An owned handle to await the termination of a service.
- Service
Metrics - Collected metrics of a single service.
- Service
Obj - Type erased
Service. - Service
Set - Spawns and keeps track of running services.
- Service
Status Error - A
ServiceErrorwithout the service error/panic. - Service
Status Join Handle - A companion handle to
ServiceJoinHandle. - Services
Metrics - A point in time snapshot of all started services and their
ServiceMetrics. - Shutdown
- Shutdown request message sent by the
Controllerto subscribed services. - Shutdown
Handle - Notifies a service about an upcoming shutdown.
- TaskId
- An identifier for tasks spawned by
spawn(), used to log metrics. - Tokio
Service Spawn - A
ServiceSpawnimplementation which spawns a service on the current Tokio runtime.
Enums§
- Shutdown
Mode - Determines how to shut down the Relay system.
Traits§
- From
Message - Declares a message as part of an
Interface. - Interface
- A message interface for services.
- Message
Response - Response behavior of an
Interfacemessage. - Service
- An asynchronous unit responding to messages.
- Service
Spawn - The
ServiceSpawntrait allows for starting aServiceon an executor that will run them to completion. - Service
Spawn Ext - Extension trait for
ServiceSpawn, providing more convenient methods to spawn a service.