Class: Datadog::Core::Cloudwise::DOCCOperationWorker
- Includes:
- Workers::Polling
- Defined in:
- lib/datadog/core/cloudwise/docc_operation_worker.rb
Overview
Worker that fetches and executes operations from DOCC every 30 seconds DOCC 操作纳管 Worker(操作拉取和结果上报)
Constant Summary collapse
- DEFAULT_INTERVAL =
30 seconds interval
30- DOCC_CODE_SUCCESS =
成功的状态码
100000- OPERATION_AGENT_START =
Operation types
'agent_start'- OPERATION_AGENT_STOP =
'agent_stop'
Constants included from Workers::Polling
Workers::Polling::DEFAULT_SHUTDOWN_TIMEOUT
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Attributes inherited from Worker
Instance Method Summary collapse
-
#initialize(client:, logger:, probe_state:, **options) ⇒ DOCCOperationWorker
constructor
A new instance of DOCCOperationWorker.
- #perform ⇒ Object
-
#start ⇒ Object
Public method to start the worker.
Methods included from Workers::Polling
#enabled=, #enabled?, included, #stop
Constructor Details
#initialize(client:, logger:, probe_state:, **options) ⇒ DOCCOperationWorker
Returns a new instance of DOCCOperationWorker.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/datadog/core/cloudwise/docc_operation_worker.rb', line 26 def initialize(client:, logger:, probe_state:, **) @client = client @logger = logger @probe_state = probe_state # Workers::Async::Thread settings self.fork_policy = .fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP) # Workers::IntervalLoop settings self.loop_base_interval = .fetch(:interval, DEFAULT_INTERVAL) self.enabled = .fetch(:enabled, true) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
24 25 26 |
# File 'lib/datadog/core/cloudwise/docc_operation_worker.rb', line 24 def client @client end |
Instance Method Details
#perform ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/datadog/core/cloudwise/docc_operation_worker.rb', line 40 def perform Cloudwise.log_debug { 'Cloudwise DOCC: Fetching operations' } result = client.docc_fetch_operation process_operation_result(result) true rescue => e Cloudwise.log_error { "Cloudwise DOCC: Operation worker error: #{e.class.name} #{e.}" } true # Continue running end |
#start ⇒ Object
Public method to start the worker
54 55 56 57 58 59 |
# File 'lib/datadog/core/cloudwise/docc_operation_worker.rb', line 54 def start return false if !enabled? || started? # Start the async worker thread perform end |