Sha256: 386efbf8704868cb405d8db9613b4c5452e96ad28ad4a0c2af4bdd0139c44f51

Contents?: true

Size: 445 Bytes

Versions: 1

Compression:

Stored size: 445 Bytes

Contents

# frozen_string_literal: true

class ConsistentRandom
  # Sidekiq server middleware that wraps job execution with consistent random scope
  # so that you can generate consistent random values within a job.
  class SidekiqMiddleware
    if defined?(Sidekiq::ServerMiddleware)
      include Sidekiq::ServerMiddleware
    end

    def call(job_instance, job_payload, queue)
      ConsistentRandom.scope do
        yield
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
consistent_random-1.0.0 lib/consistent_random/sidekiq_middleware.rb