Class: Sidekiq::Middleware::Server::RequestId

Inherits:
Logging
  • Object
show all
Defined in:
lib/sidekiq/middleware/server/request_id.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ RequestId

Returns a new instance of RequestId.



15
16
17
# File 'lib/sidekiq/middleware/server/request_id.rb', line 15

def initialize(options = nil)
  @options = options || default_options
end

Class Attribute Details

.no_resetObject

Returns the value of attribute no_reset.



12
13
14
# File 'lib/sidekiq/middleware/server/request_id.rb', line 12

def no_reset
  @no_reset
end

Instance Method Details

#call(worker, item, queue) ⇒ Object



19
20
21
22
23
24
# File 'lib/sidekiq/middleware/server/request_id.rb', line 19

def call(worker, item, queue)
  ::RequestId.set(@options[:key], @options[:value].call(item))
  yield
ensure
  ::RequestId.set(@options[:key], nil) unless self.class.no_reset
end