Class: Sidekiq::EncryptedArgs::ServerMiddleware

Inherits:
Object
  • Object
show all
Includes:
ServerMiddleware
Defined in:
lib/sidekiq/encrypted_args/server_middleware.rb

Overview

Sidekiq server middleware for decrypting arguments on jobs that have encrypted args.

This middleware is responsible for decrypting job arguments before they are passed to the worker's perform method. It runs on the server side when jobs are processed.

See Also:

Instance Method Summary collapse

Instance Method Details

#call(worker, job, queue) { ... } ⇒ void

This method returns an undefined value.

Wrap the server process to decrypt incoming arguments.

Parameters:

  • worker (Object)

    The worker instance that will process the job

  • job (Hash)

    The Sidekiq job hash containing arguments and metadata

  • queue (String)

    The name of the queue

Yields:

  • Passes control to the worker's perform method



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sidekiq/encrypted_args/server_middleware.rb', line 22

def call(worker, job, queue)
  encrypted_args = job["encrypted_args"]

  if encrypted_args
    encrypted_args = EncryptedArgs.encrypted_args_option(worker.class, job)
    job_args = job["args"]
    encrypted_args.each do |position|
      value = job_args[position]
      job_args[position] = EncryptedArgs.decrypt(value)
    end
  end

  yield
end