Sha256: fe941b00cbed5b78ce31a1291de8254e420692459924b05b129c72117699a96c

Contents?: true

Size: 614 Bytes

Versions: 2

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

# internal
require_relative "./registry"

module Sidekiq
  module Throttled
    # Server middleware that notifies strategy that job was finished.
    #
    # @private
    class Middleware
      include Sidekiq::ServerMiddleware

      # Called within Sidekiq job processing
      def call(_worker, msg, _queue)
        yield
      ensure
        job = msg.fetch("wrapped") { msg["class"] }
        jid = msg["jid"]

        if job && jid
          Registry.get job do |strategy|
            strategy.finalize!(jid, *msg["args"])
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-throttled-1.0.1 lib/sidekiq/throttled/middleware.rb
sidekiq-throttled-1.0.0 lib/sidekiq/throttled/middleware.rb