Class: Exekutor::Internal::Listener::JobParser

Inherits:
Object
  • Object
show all
Defined in:
lib/exekutor/internal/listener.rb

Overview

Parses a NOTIFY payload to a job

Constant Summary collapse

JOB_INFO_KEYS =
%w[id q p t].freeze

Class Method Summary collapse

Class Method Details

.parse(payload) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/exekutor/internal/listener.rb', line 197

def self.parse(payload)
  job_info = begin
               payload.split(";").to_h { |el| el.split(":") }
             rescue StandardError
               raise Error, "Invalid notification payload: #{payload}"
             end
  if (missing_keys = JOB_INFO_KEYS.select { |n| job_info[n].blank? }).present?
    raise Error, "[Listener] Notification payload is missing #{missing_keys.join(", ")}"
  end

  job_info
end