Module: SidekiqUniqueJobs::Middleware
- Includes:
- JSON, Logging::Middleware, OptionsWithFallback
- Defined in:
- lib/sidekiq_unique_jobs/middleware.rb,
lib/sidekiq_unique_jobs/middleware/client.rb,
lib/sidekiq_unique_jobs/middleware/server.rb
Overview
Provides the sidekiq middleware that makes the gem work
Defined Under Namespace
Instance Attribute Summary collapse
-
#item ⇒ Hash
readonly
The sidekiq job hash.
Instance Method Summary collapse
-
#call(worker_class, item, queue, redis_pool = nil) {|if| ... } ⇒ yield<super>
This method runs before (prepended) the actual middleware implementation.
Methods included from JSON
dump_json, load_json, safe_load_json
Methods included from OptionsWithFallback
included, #lock_class, #lock_instance, #lock_type, #locks, #options, #unique_disabled?, #unique_enabled?
Methods included from Logging::Middleware
Methods included from Logging
#build_message, included, #log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context, #with_configured_loggers_context, #with_logging_context
Instance Attribute Details
#item ⇒ Hash (readonly)
The sidekiq job hash
16 17 18 |
# File 'lib/sidekiq_unique_jobs/middleware.rb', line 16 def item @item end |
Instance Method Details
#call(worker_class, item, queue, redis_pool = nil) {|if| ... } ⇒ yield<super>
This method runs before (prepended) the actual middleware implementation.
This is done to reduce duplication
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sidekiq_unique_jobs/middleware.rb', line 31 def call(worker_class, item, queue, redis_pool = nil) @item = item @queue = queue @redis_pool = redis_pool self.job_class = worker_class return yield if unique_disabled? SidekiqUniqueJobs::Job.prepare(item) unless item[LOCK_DIGEST] with_logging_context do super end end |