#[derive(Command)]
{
// Attributes available to this derive:
#[subject]
#[command]
}
Expand description
Re-exported so services only need to depend on arminius-lib-nats.
The message-bus Subscriber trait
is intentionally not re-exported here to avoid clashing with the
async_nats::Subscriber re-export above; reach it via
arminius_lib_message_bus::Subscriber.
Derive macro that implements arminius_lib_message_bus::Command for a
struct.
§Attributes
#[subject(...)]— the NATS subject the command is sent on. Accepts a bare literal (#[subject("rooms.create")]) or thename = "...", version = ...form (which appends.v{version}).#[command(reply = Type)]— the reply type returned by the handler.
§Subject rules (differ from Event)
- No struct-name fallback. A command must name an explicit subject, so it has a namespace
segment for its stream filter; a namespace-less subject would collapse to the catch-all
>filter. - No
compatiblelist.
§Payload and dynamic subjects
The whole struct is serialized as the request payload, so the command must
also derive serde::Serialize and serde::Deserialize. Any number of
fields is allowed.
Fields named in {…} placeholders become wildcard segments in the subject:
the derive interpolates them from the struct’s own fields, so the subject
and the payload copies cannot drift.
§Example
#[derive(Serialize, Deserialize, Command)]
#[subject("rooms.{room_id}.create")]
#[command(reply = Result<OwnedRoomId, CreateRoomError>)]
pub struct CreateRoomCommand {
pub room_id: OwnedRoomId,
pub name: String,
pub preset: RoomPreset,
}#[command(...)] also takes delivery = at_least_once | at_most_once.
For a detailed explanation look at
arminius_lib_message_bus::command::Delivery.