Class: Wurk::Client::Buffered::DropLog
- Inherits:
-
Object
- Object
- Wurk::Client::Buffered::DropLog
- Defined in:
- lib/wurk/client/buffered.rb
Overview
The jobs :drop_oldest evicts. A drop is a job the caller was told was
enqueued and that will now never run, so it must never be silent. One
ERROR per burst — the first drop since a replay last reached Redis —
because an outage that outlasts the cap drops on every push, and a line
per job would bury the one that says what happened. Every drop still
counts, as the statsd jobs.dropped.push counter.
#record runs under the buffer's mutex; #report runs after it is released, so neither the log write nor statsd holds up other pushes.
Instance Method Summary collapse
-
#end_burst ⇒ Object
A replay reached Redis, so the outage that filled the buffer is over: the next overflow is a new incident and gets its own ERROR.
-
#initialize ⇒ DropLog
constructor
A new instance of DropLog.
- #record(payload) ⇒ Object
- #report(cap, bytes_cap = nil) ⇒ Object
Constructor Details
#initialize ⇒ DropLog
Returns a new instance of DropLog.
686 687 688 689 690 |
# File 'lib/wurk/client/buffered.rb', line 686 def initialize @lock = Mutex.new @pending = [] @burst = false end |
Instance Method Details
#end_burst ⇒ Object
A replay reached Redis, so the outage that filled the buffer is over: the next overflow is a new incident and gets its own ERROR.
714 715 716 |
# File 'lib/wurk/client/buffered.rb', line 714 def end_burst @lock.synchronize { @burst = false } end |
#record(payload) ⇒ Object
692 693 694 |
# File 'lib/wurk/client/buffered.rb', line 692 def record(payload) @lock.synchronize { @pending << payload } end |
#report(cap, bytes_cap = nil) ⇒ Object
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
# File 'lib/wurk/client/buffered.rb', line 696 def report(cap, bytes_cap = nil) dropped, announce = @lock.synchronize do next [nil, false] if @pending.empty? taken = @pending @pending = [] first = !@burst @burst = true [taken, first] end return unless dropped log(dropped.first, cap, bytes_cap) if announce dropped.size.times { count_drop } end |