Enum svc_agent::Source[][src]

pub enum Source<'a> {
    Broadcast(&'a AccountId, &'a str, &'a str),
    Multicast(Option<&'a AgentId>, Option<&'a str>),
    Unicast(Option<&'a AccountId>),
}
Expand description

Message source.

This is an abstraction over MQTT topic pattern to determine the subscription topic to receive messages.

If you want to subscribe to a topic consider using Subscription builder or building RequestSubscription, ResponseSubscription or EventSubscription directly when you need something special.

Understanding message routing is the key thing to use svc-agent. Make sure that you understand the patterns below and their counterparts described in Destination.

MQTT topic variables:

  • MY_ACCOUNT_IDAccountId of the current agent that send the message.
  • MY_VER – API version string of the current agent. For example: v1.
  • ACCOUNT_ID – source AccountId (no specific agent).
  • AGENT_ID – source AgentId.
  • VER – source agent version.
  • BROADCAST_URI source agent’s API specific path to some resource divided by /. For example: /rooms/ROOM_ID/events. Use + as single-level wildcard like /room/+/events to subscribe to events in all rooms and # as multi-level wildcard like /rooms/# to subscribe to all rooms and their nested resources.

Variants

Broadcast(&'a AccountId, &'a str, &'a str)

Receive a message along with other subscribers.

Typically used for receiving notification events from a service.

Value supplied are ACCOUNT_ID, VER and BROADCAST_URI.

Patterns

TypePatternMQTT topic
eventany-from-appapps/ACCOUNT_ID/api/VER/BROADCAST_URI

Tuple Fields of Broadcast

0: &'a AccountId1: &'a str2: &'a str
Multicast(Option<&'a AgentId>, Option<&'a str>)

Receive a message from any single of SharedGroup agents.

Typically used for receiving requests by services which may have multiple instances.

AccountId is being supplied since we don’t care which specific instance will process the message.

Optional values supplied are AGENT_ID and VER. If None is specified for either of the two then wildcard is being used to receive messages from any agent or its API version.

Patterns

TypePatternMQTT topic
requestapp-from-anyagents/+/api/+/out/MY_ACCOUNT_ID
requestapp-from-anyagents/+/api/VER/out/MY_ACCOUNT_ID
requestapp-from-anyagents/AGENT_ID/api/+/out/MY_ACCOUNT_ID
requestapp-from-anyagents/AGENT_ID/api/VER/out/MY_ACCOUNT_ID

Tuple Fields of Multicast

0: Option<&'a AgentId>1: Option<&'a str>
Unicast(Option<&'a AccountId>)

Receive a message sent specifically to the current agent by its AGENT_ID.

Typically being used for receiving responses for requests. Also used for receiving a request by a specific instance of a stateful service.

Optional ACCOUNT_ID may be supplied to specify an AccountId to subscribe to. If None is specified then wildcard is being used to receive unicast messages from any account.

Patterns

TypePatternMQTT topic
requestone-from-oneagents/MY_AGENT_ID/api/MY_VER/in/ACCOUNT_ID
requestone-from-anyagents/MY_AGENT_ID/api/MY_VER/in/+
responseone-from-oneagents/MY_AGENT_ID/api/MY_VER/in/ACCOUNT_ID
responseone-from-anyagents/MY_AGENT_ID/api/MY_VER/in/+

Tuple Fields of Unicast

0: Option<&'a AccountId>

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.