Sha256: 8901ce62ecd916a2da0a1d5da26010a88bab28bb58b463cf83fbfe652462c8a2
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# typed: false require 'ddtrace/workers/async' require 'ddtrace/workers/interval_loop' module Datadog module Workers # Adds polling (async looping) behavior to workers module Polling SHUTDOWN_TIMEOUT = 1 def self.included(base) base.include(Workers::IntervalLoop) base.include(Workers::Async::Thread) base.prepend(PrependedMethods) end # Methods that must be prepended module PrependedMethods def perform(*args) super if enabled? end end def stop(force_stop = false, timeout = 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 def enabled? return true unless instance_variable_defined?(:@enabled) @enabled end # Allow worker to be started def enabled=(value) # Coerce to boolean @enabled = (value == true) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ddtrace-0.54.2 | lib/ddtrace/workers/polling.rb |