Sha256: e2c67082881bda8298cda20f79f296d7ad5d0a84e92c95fefe9c0bdabf798e10

Contents?: true

Size: 464 Bytes

Versions: 1

Compression:

Stored size: 464 Bytes

Contents

module DistributeReads
  module GlobalMethods
    def distribute_reads(max_lag: nil)
      previous_value = Thread.current[:distribute_reads]
      begin
        if max_lag && DistributeReads.lag > max_lag
          raise DistributeReads::TooMuchLag, "Replica lag over #{max_lag} seconds"
        end
        Thread.current[:distribute_reads] = true
        yield
      ensure
        Thread.current[:distribute_reads] = previous_value
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
distribute_reads-0.1.0 lib/distribute_reads/global_methods.rb