lib/sidekiq-status/client_middleware.rb in sidekiq-status-0.6.0 vs lib/sidekiq-status/client_middleware.rb in sidekiq-status-0.7.0

- old
+ new

@@ -1,5 +1,6 @@ +require 'sidekiq/api' module Sidekiq::Status # Should be in the client middleware chain class ClientMiddleware include Storage @@ -15,16 +16,24 @@ # @param [Class] worker_class if includes Sidekiq::Status::Worker, the job gets processed with the plugin # @param [Array] msg job arguments # @param [String] queue the queue's name # @param [ConnectionPool] redis_pool optional redis connection pool def call(worker_class, msg, queue, redis_pool=nil) - initial_metadata = { + initial_metadata = { jid: msg['jid'], status: :queued, - worker: worker_class, - args: msg['args'].to_a.empty? ? nil : msg['args'].to_json + worker: Sidekiq::Job.new(msg, queue).display_class, + args: display_args(msg, queue) } store_for_id msg['jid'], initial_metadata, @expiration, redis_pool yield end + + def display_args(msg, queue) + job = Sidekiq::Job.new(msg, queue) + return job.display_args.to_a.empty? ? nil : job.display_args.to_json + rescue Exception => e + # For Sidekiq ~> 2.7 + return msg['args'].to_a.empty? ? nil : msg['args'].to_json + end end -end \ No newline at end of file +end