Class: Nucleus::Adapters::V1::CloudControl::Logs::LogPoller
- Inherits:
-
Object
- Object
- Nucleus::Adapters::V1::CloudControl::Logs::LogPoller
- Defined in:
- lib/nucleus/adapters/v1/cloud_control/log_poller.rb
Instance Method Summary collapse
-
#initialize(adapter, headers_to_use) ⇒ LogPoller
constructor
Initialize a new instance.
-
#start(application_name, logs_to_poll, stream) ⇒ void
Start the continuous polling of the logs.
-
#stop ⇒ Object
Stop the polling at the next shot.
Constructor Details
#initialize(adapter, headers_to_use) ⇒ LogPoller
Initialize a new instance
12 13 14 15 16 |
# File 'lib/nucleus/adapters/v1/cloud_control/log_poller.rb', line 12 def initialize(adapter, headers_to_use) @adapter = adapter @headers_to_use = headers_to_use @last_log_entry = {} end |
Instance Method Details
#start(application_name, logs_to_poll, stream) ⇒ void
This method returns an undefined value.
Start the continuous polling of the logs.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/nucleus/adapters/v1/cloud_control/log_poller.rb', line 23 def start(application_name, logs_to_poll, stream) @polling_active = true # 1 log: wait 4 seconds between polls # 4 logs: 1 seconds timeout = logs_to_poll.length == 1 ? 4 : 1 logs_to_poll.each { |log_to_poll| @last_log_entry[log_to_poll] = nil } fetch_action = lambda do update_log(application_name, logs_to_poll, stream) # start next iteration if we are still supposed to be active EM.add_timer(timeout) { fetch_action.call } if @polling_active end # start the loop to poll the logs EM.add_timer(timeout) { fetch_action.call } end |
#stop ⇒ Object
Stop the polling at the next shot
40 41 42 |
# File 'lib/nucleus/adapters/v1/cloud_control/log_poller.rb', line 40 def stop @polling_active = false end |