Module moleculer::service [−][src]
Create Service struct with Events and Actions.
let greeter_service = Service::new("rustGreeter") .add_event(print_hi) .add_event(print_name) .add_action(math_action); // callback for first event, will be called whenever "printHi" event is received fn print_hi(_ctx: Context<Event>) -> Result<(), Box<dyn Error>> { {...} } // callback for second event, will be called whenever "printName" event is received fn print_name(ctx: Context<Event>) -> Result<(), Box<dyn Error>> { {...} } // callback for math action fn math_add(ctx: Context<Action>) -> Result<(), Box<dyn Error>> { {...} }
Structs
Action | Build using ActionBuilder. |
ActionBuilder | Builder for Action |
Context | Context is available in all callbacks. |
Event | Build using EventBuilder |
EventBuilder | Builder for Event. |
Service |
Enums
EventType |
Type Definitions
Callback | Function that is called when an Event or Action is received. |