[][src]Enum svc_agent::Source

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

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.

Understaging 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
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
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/+

Trait Implementations

impl<'a> Debug for Source<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Source<'a>

impl<'a> Send for Source<'a>

impl<'a> Sync for Source<'a>

impl<'a> Unpin for Source<'a>

impl<'a> UnwindSafe for Source<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,