Module: Datadog::Core::Workers::Polling
- Included in:
- Telemetry::Worker, RuntimeMetrics, Profiling::Scheduler, Tracing::Workers::AsyncTraceWriter
- Defined in:
- lib/datadog/core/workers/polling.rb
Overview
Adds polling (async looping) behavior to workers
Defined Under Namespace
Modules: PrependedMethods
Constant Summary collapse
- DEFAULT_SHUTDOWN_TIMEOUT =
1
Class Method Summary collapse
Instance Method Summary collapse
-
#enabled=(value) ⇒ Object
Allow worker to be started.
- #enabled? ⇒ Boolean
- #stop(force_stop = false, timeout = DEFAULT_SHUTDOWN_TIMEOUT) ⇒ Object
Class Method Details
.included(base) ⇒ Object
11 12 13 14 15 |
# File 'lib/datadog/core/workers/polling.rb', line 11 def self.included(base) base.include(Workers::IntervalLoop) base.include(Workers::Async::Thread) base.prepend(PrependedMethods) end |
Instance Method Details
#enabled=(value) ⇒ Object
Allow worker to be started
50 51 52 53 |
# File 'lib/datadog/core/workers/polling.rb', line 50 def enabled=(value) # Coerce to boolean @enabled = (value == true) end |
#enabled? ⇒ Boolean
43 44 45 46 47 |
# File 'lib/datadog/core/workers/polling.rb', line 43 def enabled? return true unless instance_variable_defined?(:@enabled) @enabled end |
#stop(force_stop = false, timeout = DEFAULT_SHUTDOWN_TIMEOUT) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/datadog/core/workers/polling.rb', line 24 def stop(force_stop = false, timeout = DEFAULT_SHUTDOWN_TIMEOUT) if running? # Attempt graceful stop and wait stop_loop graceful = join(timeout) if !graceful && force_stop Datadog.logger.debug do "Timeout while waiting for worker to finish gracefully, forcing termination for: #{self}" end terminate else graceful end else false end end |