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.

  1. 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 on ractor::message::SerializedMessage::Cast and Call.
  2. All properties of the message MUST implement the ractor::BytesConvertable trait which means they supply a to_bytes and from_bytes method. Many types are pre-done for you in ractor’s definition of the trait
  3. 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
  4. 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
  5. For backwards compatibility, you can add new variants as long as you don’t rename variants until all nodes in the cluster are upgraded.