Struct moleculer::service::Context[][src]

pub struct Context<T> {
    pub id: String,
    pub broker: ServiceBroker,
    pub node_id: String,
    pub action: Option<String>,
    pub event_name: Option<String>,
    pub event_type: Option<EventType>,
    pub event_groups: Vec<String>,
    pub caller: Option<String>,
    pub request_id: Option<String>,
    pub parent_id: Option<String>,
    pub params: Value,
    pub meta: Value,
    pub locals: Option<Value>,
    pub level: i32,
    // some fields omitted
}

Context is available in all callbacks.

In an action context you can send a response to the request using reply()

In all contexts emit(), broadcast() and call() are available

Fields

id: Stringbroker: ServiceBrokernode_id: Stringaction: Option<String>event_name: Option<String>event_type: Option<EventType>event_groups: Vec<String>caller: Option<String>request_id: Option<String>parent_id: Option<String>params: Valuemeta: Valuelocals: Option<Value>level: i32

Implementations

impl Context<Action>[src]

pub fn reply(&self, params: Value)[src]

impl<T> Context<T>[src]

pub fn emit<S: Into<String>>(&self, event: S, params: Value)[src]

pub fn broadcast<S: Into<String>>(&self, event: S, params: Value)[src]

pub async fn call<S: Into<String>>(
    self,
    action: S,
    params: Value
) -> Result<Value, Error>
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Context<T>

impl<T> Send for Context<T> where
    T: Send

impl<T> Sync for Context<T> where
    T: Sync

impl<T> Unpin for Context<T> where
    T: Unpin

impl<T> !UnwindSafe for Context<T>

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> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

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>,