[−][src]Enum svc_agent::Source
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_ID
– AccountId 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
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
Type | Pattern | MQTT topic |
---|---|---|
event | any-from-app | apps/ACCOUNT_ID /api/VER /BROADCAST_URI |
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
Type | Pattern | MQTT topic |
---|---|---|
request | app-from-any | agents/+/api/+/out/MY_ACCOUNT_ID |
request | app-from-any | agents/+/api/VER/out/MY_ACCOUNT_ID |
request | app-from-any | agents/AGENT_ID /api/+/out/MY_ACCOUNT_ID |
request | app-from-any | agents/AGENT_ID /api/VER/out/MY_ACCOUNT_ID |
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
Type | Pattern | MQTT topic |
---|---|---|
request | one-from-one | agents/MY_AGENT_ID /api/MY_VER /in/ACCOUNT_ID |
request | one-from-any | agents/MY_AGENT_ID /api/MY_VER /in/+ |
response | one-from-one | agents/MY_AGENT_ID /api/MY_VER /in/ACCOUNT_ID |
response | one-from-any | agents/MY_AGENT_ID /api/MY_VER /in/+ |
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,