Class: Undertow::DrainJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Undertow::DrainJob
- Defined in:
- lib/undertow/drain_job.rb
Overview
Drains the per-model Redis buffers and delivers batches of dirty IDs to each model's configured sinks.
Publishes two ActiveSupport::Notifications events, once per sink (per chunk, if a sink's max_batch_size is smaller than the popped batch):
drain.undertow , after a successful sink call ({ model:, sink:, upserted_ids:, deleted_ids:, duration_ms: })
error.undertow , when a sink raises ({ model:, sink:, exception: })
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/undertow/drain_job.rb', line 14 def perform # Release the lock before draining so the scheduler can enqueue another job # for IDs that arrive while this one is running. Buffer.release_drain_lock model_names = Buffer.pending_model_names return if model_names.empty? model_names.each { |name| drain_model(name) } end |