Class: RailsTransactionalOutbox::LatencyTracker
- Inherits:
-
Object
- Object
- RailsTransactionalOutbox::LatencyTracker
- Defined in:
- lib/rails_transactional_outbox/latency_tracker.rb
Instance Method Summary collapse
- #calculate(interval: 1.minute) ⇒ Object
-
#initialize(config: RailsTransactionalOutbox.configuration, clock: Time) ⇒ LatencyTracker
constructor
A new instance of LatencyTracker.
Constructor Details
#initialize(config: RailsTransactionalOutbox.configuration, clock: Time) ⇒ LatencyTracker
Returns a new instance of LatencyTracker.
11 12 13 14 |
# File 'lib/rails_transactional_outbox/latency_tracker.rb', line 11 def initialize(config: RailsTransactionalOutbox.configuration, clock: Time) @config = config @clock = clock end |
Instance Method Details
#calculate(interval: 1.minute) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rails_transactional_outbox/latency_tracker.rb', line 16 def calculate(interval: 1.minute) records = outbox_model.processed_since(interval.ago) latencies = records.map(&:processing_latency) LatencyTrackerResult.new( latencies.min.to_d, latencies.max.to_d, calculate_average(latencies), calculate_highest_since_creation_date.to_d ) end |