Class: Yes::Command::Api::Commands::Notifiers::ActionCable
- Inherits:
-
Yes::Core::Commands::Notifier
- Object
- Yes::Core::Commands::Notifier
- Yes::Command::Api::Commands::Notifiers::ActionCable
- Defined in:
- lib/yes/command/api/commands/notifiers/action_cable.rb
Overview
Notifies command processing events via ActionCable broadcast. Used with an external WebSocket gateway (e.g. socket_gate).
Instance Method Summary collapse
- #notify_batch_finished(batch_id, transaction = nil, responses = nil) ⇒ Object
- #notify_batch_started(batch_id, transaction = nil, commands = nil) ⇒ Object
- #notify_command_response(cmd_response) ⇒ Object
Instance Method Details
#notify_batch_finished(batch_id, transaction = nil, responses = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/yes/command/api/commands/notifiers/action_cable.rb', line 29 def notify_batch_finished(batch_id, transaction = nil, responses = nil) ::ActionCable.server.broadcast( channel, { batch_id:, published_at:, type: 'batch_finished', transaction: transaction.to_h }.merge(failed_commands_data(responses)) ) end |
#notify_batch_started(batch_id, transaction = nil, commands = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/yes/command/api/commands/notifiers/action_cable.rb', line 14 def notify_batch_started(batch_id, transaction = nil, commands = nil) ::ActionCable.server.broadcast( channel, { batch_id:, published_at:, type: 'batch_started', transaction: transaction.to_h }.merge(commands_data(commands)) ) end |
#notify_command_response(cmd_response) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/yes/command/api/commands/notifiers/action_cable.rb', line 42 def notify_command_response(cmd_response) ::ActionCable.server.broadcast( channel, cmd_response.to_notification.merge(published_at:) ) end |