Class: DynoscaleRuby::Reporter
- Inherits:
-
Object
- Object
- DynoscaleRuby::Reporter
- Extended by:
- Logger
- Includes:
- Singleton
- Defined in:
- lib/dynoscale_ruby/reporter.rb
Constant Summary collapse
- REPORT_PUBLISH_FREQ =
Production delays
30
- REPORT_PUBLISH_RETRY_FREQ =
seconds
15
Class Method Summary collapse
- .report_publish_freq ⇒ Object
- .report_publish_retry_freq ⇒ Object
- .running? ⇒ Boolean
-
.start!(recorder, api_wrapper, break_after_first_iteration: false) ⇒ Object
seconds.
Methods included from Logger
Class Method Details
.report_publish_freq ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dynoscale_ruby/reporter.rb', line 42 def self.report_publish_freq is_dev = ENV['DYNOSCALE_DEV'] == 'true' if is_dev 0 elsif @@config && @@config['publish_frequency'] @@config['publish_frequency']&.to_i || REPORT_PUBLISH_FREQ else REPORT_PUBLISH_FREQ end end |
.report_publish_retry_freq ⇒ Object
53 54 55 56 |
# File 'lib/dynoscale_ruby/reporter.rb', line 53 def self.report_publish_retry_freq is_dev = ENV['DYNOSCALE_DEV'] == 'true' is_dev ? 0 : REPORT_PUBLISH_RETRY_FREQ end |
.running? ⇒ Boolean
37 38 39 40 |
# File 'lib/dynoscale_ruby/reporter.rb', line 37 def self.running? @@reporter_thread ||= nil !!@@reporter_thread && @@reporter_thread.alive? end |
.start!(recorder, api_wrapper, break_after_first_iteration: false) ⇒ Object
seconds
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dynoscale_ruby/reporter.rb', line 14 def self.start!(recorder, api_wrapper, break_after_first_iteration: false) @@reporter_thread ||= Thread.start do loop do if recorder.reports.any?(&:ready_to_publish?) api_wrapper.publish_reports(recorder.reports) do |success, published_reports, config| if success recorder.remove_published_reports!(published_reports) @@config = config Logger.logger.debug "Report publish was successful" sleep report_publish_freq else Logger.logger.error "Report publish failed" sleep report_publish_retry_freq end end else sleep report_publish_retry_freq end break if break_after_first_iteration end end end |