Add deduplication for JSON payloads in job queue
This commit is contained in:
parent
30453fab80
commit
1bfbfb0317
8 changed files with 163 additions and 2 deletions
25
lib/argument_deduplication/client.rb
Normal file
25
lib/argument_deduplication/client.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ArgumentDeduplication
|
||||
class Client
|
||||
include Sidekiq::ClientMiddleware
|
||||
|
||||
def call(_worker, job, _queue, _redis_pool)
|
||||
process_arguments!(job)
|
||||
yield
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def process_arguments!(job)
|
||||
return unless job['deduplicate_arguments']
|
||||
|
||||
argument_index = job['deduplicate_arguments']
|
||||
argument = Argument.from_value(job['args'][argument_index])
|
||||
|
||||
argument.push!
|
||||
|
||||
job['args'][argument_index] = argument.content_hash
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue