Class: SolidObserver::Services::CableStats::StabilityData

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_observer/services/cable_stats.rb

Instance Method Summary collapse

Constructor Details

#initialize(window:, current_time:, backlog_snapshot:) ⇒ StabilityData

Returns a new instance of StabilityData.



153
154
155
156
157
# File 'lib/solid_observer/services/cable_stats.rb', line 153

def initialize(window:, current_time:, backlog_snapshot:)
  @window = window
  @current_time = current_time
  @backlog_snapshot = backlog_snapshot
end

Instance Method Details

#to_h(metric_broadcasts_count:, metric_rejections_count:) ⇒ Object



159
160
161
162
163
164
165
166
# File 'lib/solid_observer/services/cable_stats.rb', line 159

def to_h(metric_broadcasts_count:, metric_rejections_count:)
  compute(
    metric_broadcasts_count: metric_broadcasts_count,
    metric_rejections_count: metric_rejections_count
  ).to_h
rescue ActiveRecord::StatementInvalid
  CableStats::STABILITY_DEGRADED.dup
end