Class: Karafka::Web::Pro::Commanding::Dispatcher
- Inherits:
-
Object
- Object
- Karafka::Web::Pro::Commanding::Dispatcher
- Defined in:
- lib/karafka/web/pro/commanding/dispatcher.rb
Overview
Dispatcher for sending commanding related messages. Those can be: - command (do something) - result (you wanted me to get you some info, here it is)
Dispatcher requires Web UI to have a producer
Constant Summary collapse
- SCHEMA_VERSION =
What schema do we have in current Karafka version for commands dispatches
'1.0.0'
Class Method Summary collapse
-
.command(name, process_id) ⇒ Object
Dispatches the command request.
-
.result(result, process_id, command_name) ⇒ Object
Dispatches the result request.
Class Method Details
.command(name, process_id) ⇒ Object
Dispatches the command request
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/karafka/web/pro/commanding/dispatcher.rb', line 33 def command(name, process_id) produce( process_id, { schema_version: SCHEMA_VERSION, type: 'command', command: { name: name }, dispatched_at: Time.now.to_f, process: { id: process_id } } ) end |
.result(result, process_id, command_name) ⇒ Object
Dispatches the result request
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/karafka/web/pro/commanding/dispatcher.rb', line 55 def result(result, process_id, command_name) produce( process_id, { schema_version: SCHEMA_VERSION, type: 'result', command: { name: command_name }, result: result, dispatched_at: Time.now.to_f, process: { id: process_id } } ) end |