Class: Katello::Agent::ClientMessageHandler
- Inherits:
-
Object
- Object
- Katello::Agent::ClientMessageHandler
- Defined in:
- app/lib/katello/agent/client_message_handler.rb
Instance Method Summary collapse
- #accepted? ⇒ Boolean
- #handle ⇒ Object
-
#initialize(message) ⇒ ClientMessageHandler
constructor
A new instance of ClientMessageHandler.
- #result ⇒ Object
Constructor Details
#initialize(message) ⇒ ClientMessageHandler
Returns a new instance of ClientMessageHandler.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/lib/katello/agent/client_message_handler.rb', line 4 def initialize() logger.debug("client message: #{.body}") @json = () dispatch_history_id = @json&.dig(:data, :dispatch_history_id) @dispatch_history = Katello::Agent::DispatchHistory.find_by_id(dispatch_history_id) unless @dispatch_history logger.error("Invalid client message: #{@json}") fail("No valid dispatch history in client message") end end |
Instance Method Details
#accepted? ⇒ Boolean
16 17 18 |
# File 'app/lib/katello/agent/client_message_handler.rb', line 16 def accepted? @json[:status] == 'accepted' end |
#handle ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/lib/katello/agent/client_message_handler.rb', line 24 def handle @dispatch_history.accepted_at = DateTime.now if accepted? @dispatch_history.result = result if result @dispatch_history.save! if @dispatch_history.dynflow_execution_plan_id && @dispatch_history.dynflow_step_id handle_dynflow_event end end |
#result ⇒ Object
20 21 22 |
# File 'app/lib/katello/agent/client_message_handler.rb', line 20 def result @json.dig(:result, :retval, :details) end |