Class: Sidekiq::EncryptedArgs::ClientMiddleware

Inherits:
Object
  • Object
show all
Includes:
ClientMiddleware
Defined in:
lib/sidekiq/encrypted_args/client_middleware.rb

Overview

Sidekiq client middleware for encrypting arguments on jobs for workers with encrypted_args set in the sidekiq_options.

This middleware is responsible for encrypting job arguments before they are sent to Redis. It runs on the client side when jobs are enqueued.

See Also:

Instance Method Summary collapse

Instance Method Details

#call(worker_class, job, queue, redis_pool = nil) { ... } ⇒ void

This method returns an undefined value.

Encrypt specified arguments before they're sent off to the queue.

Parameters:

  • worker_class (String, Class)

    The worker class or class name

  • job (Hash)

    The Sidekiq job hash containing arguments and metadata

  • queue (String)

    The name of the queue

  • redis_pool (Object, nil) (defaults to: nil)

    Optional Redis connection pool (legacy parameter)

Yields:

  • Passes control to the next middleware in the chain



23
24
25
26
27
28
29
30
# File 'lib/sidekiq/encrypted_args/client_middleware.rb', line 23

def call(worker_class, job, queue, redis_pool = nil)
  if job.include?("encrypted_args")
    encrypted_args = EncryptedArgs.encrypted_args_option(worker_class, job)
    encrypt_job_arguments!(job, encrypted_args)
  end

  yield
end