pub enum Destination {
    Broadcast(String),
    Multicast(AccountId, String),
    Unicast(AgentId, String),
}
Expand description

Message destination.

This is an abstraction over MQTT topic pattern to determine outgoing message’s publish topic.

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

MQTT topic variables:

  • MY_ACCOUNT_IDAccountId of the current agent that sends the message.
  • MY_VER – API version string of the current agent. For example: v1.
  • MY_BROADCAST_URI– current agent’s API specific path to some resource divided by /. For example: /rooms/ROOM_ID/events. If you will want to change its structure in the future you must also bump VER(ME).
  • ACCOUNT_ID – destination AccountId (no specific agent).
  • AGENT_ID – destination AgentId.
  • VER – destination agent version.

Variants§

§

Broadcast(String)

Publish a message to each of the topic subscribers.

Typically being used for publishing notification events from a service.

The string supplied is MY_BROADCAST_URI.

Patterns
TypePatternMQTT topic
eventapp-to-anyapps/MY_ACCOUNT_ID/api/MY_VER/MY_BROADCAST_URI
§

Multicast(AccountId, String)

Publish a message to any single of SharedGroup agents.

Typically being used for sending requests to services which may have multiple instances.

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

Patterns
TypePatternMQTT topic
requestone-to_appagents/MY_AGENT_ID/api/MY_VER/out/ACCOUNT_ID
§

Unicast(AgentId, String)

Publish a message to the specific instance with known AGENT_ID.

Typically being used for responding to requests. Also used for making a request to a specific instance of a stateful service.

Values supplied are AGENT_ID and VER.

Patterns
TypePatternMQTT topic
requestone-to-oneagents/AGENT_ID/api/VER/in/MY_ACCOUNT_ID
responseone-to_oneagents/AGENT_ID/api/VER/in/MY_ACCOUNT_ID

Trait Implementations§

source§

impl Debug for Destination

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.