Struct moleculer::ServiceBroker [−][src]
pub struct ServiceBroker { /* fields omitted */ }
Expand description
The struct used to interact with moleculer.
Use emit()
, broadcast()
and call()
functions.
ⓘ
// emit an event broker.emit("printHi", json!{{}}); // broadcast an event broker.broadcast("printHi", json!{{}}); // call an action let result = broker.call("math.add", json!{"a": 1, "b": c}).await?;
Implementations
Create new service broker, takes Config struct.
Add a service to the service broker.
Add all the services to the service broker at once. Takes a vector of services and replaces any services the broker already had.
Starts the service, this will run forever until your application exits.
Request/Response style call
Call an action directly with params serialized into
serde_json::Value and await
on the result
Emits a balanced event to one of the nodes.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for ServiceBroker
impl Send for ServiceBroker
impl Sync for ServiceBroker
impl Unpin for ServiceBroker
impl !UnwindSafe for ServiceBroker
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self