Class: Sidekiq::Compress::ClientMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq-compress/client_middleware.rb

Overview

Should be in the client middleware chain

Instance Method Summary collapse

Instance Method Details

#call(worker, msg, queue, redis_pool) ⇒ Object

Uses msg id and puts :queued status in the job’s Redis hash

Parameters:

  • worker_class (Class)

    if includes Sidekiq::Status::Worker, the job gets processed with the plugin

  • msg (Array)

    job arguments

  • queue (String)

    the queue’s name

  • redis_pool (ConnectionPool)

    optional redis connection pool



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sidekiq-compress/client_middleware.rb', line 11

def call(worker, msg, queue, redis_pool)
  # return false/nil to stop the job from going to redis
  klass = msg["args"][0]["job_class"] || msg["class"] rescue msg["class"]
  job_class = klass.is_a?(Class) ? klass : Module.const_get(klass)
  unless job_class.ancestors.include?(Sidekiq::Compress)
    yield
    return
  end

  msg["args"] = Sidekiq::Compress::CompressParams.call(msg["args"])

  yield
end