Derive Macro ractor_cluster::RactorClusterMessage
source · #[derive(RactorClusterMessage)]
{
// Attributes available to this derive:
#[rpc]
}
Expand description
Derive ractor::Message
for messages that can be sent over the network
Serializable messages have to have a few formatting requirements.
- All variants of the enum will be tagged based on their variant name, which is sent over-the-wire in order to decode which
variant was called. This is the
variant
field onractor::message::SerializedMessage::Cast
andCall
. - All properties of the message MUST implement the
ractor::BytesConvertable
trait which means they supply ato_bytes
andfrom_bytes
method. Many types are pre-done for you inractor
’s definition of the trait - For RPCs, the LAST argument must be the reply channel. Additionally the type of message the channel is expecting back must also implement
ractor::BytesConvertable
- Lastly, for RPCs, they should additionally be decorated with
#[rpc]
on each variant’s definition. This helps the macro identify that it is an RPC and will need port handler - For backwards compatibility, you can add new variants as long as you don’t rename variants until all nodes in the cluster are upgraded.