Class: Sidekiq::Dry::Server::DeserializationMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/dry/server/deserialization_middleware.rb

Overview

Middleware which instantiates ‘Dry::Struct` hash arguments

Instance Method Summary collapse

Instance Method Details

#call(_worker, job, _queue) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sidekiq/dry/server/deserialization_middleware.rb', line 8

def call(_worker, job, _queue)
  original_args = job['args']

  job['args'] = job['args'].map do |arg|
    # Only mutate Dry::Struct hashes
    next arg unless struct?(arg)

    to_struct(arg)
  end

  yield
rescue Exception => _ex
  # Other middlewares will see the Hash arguments
  # which might be handled more predictably in cases
  # like exception tracking where the job arguments
  # commonly get processed to redact sensitive info
  job['args'] = original_args

  raise
end