Class: SolidObserver::Services::CableStats::BacklogSnapshot

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



120
121
122
# File 'lib/solid_observer/services/cable_stats.rb', line 120

def self.call
  new.call
end

Instance Method Details

#callObject

:reek:TooManyStatements



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/solid_observer/services/cable_stats.rb', line 125

def call
  snapshot = fetch_snapshot
  return unavailable unless snapshot && snapshot[:available]

  count = snapshot[:trimmable_count].to_i
  total = snapshot[:event_count].to_i

  {
    available: true,
    count: count,
    ratio: total.positive? ? count.to_f / total.to_f : 0.0
  }
rescue *StorageInfoSnapshot::CONNECTION_ERRORS, TypeError, NoMethodError
  unavailable
end