Class: Datadog::Core::Cloudwise::LicenseWorker
- Includes:
- Workers::Polling
- Defined in:
- lib/datadog/core/cloudwise/license_worker.rb
Overview
Worker that verifies license every 5 minutes with retry mechanism License 校验失败或接口失败 3 次,数据不采集
Constant Summary collapse
- DEFAULT_INTERVAL =
5 minutes interval (300 seconds)
300- MAX_RETRIES =
Max retries: 3 times (累计失败次数)
3- CODE_SUCCESS =
成功的状态码
1000- FUSE_STATE_NORMAL =
熔断状态定义
0- FUSE_STATE_FUSING =
正常
1- FUSE_DESCRIBE_LICENSE_EXPIRED =
熔断描述定义
7- FUSE_DESCRIBE_AGENT_SUSPENDED =
License过期熔断
8- FUSE_DESCRIBE_LICENSE_OVER_QUOTA =
Agent暂停熔断
9- FUSE_DESCRIBE_LICENSE_INTERFACE_ERROR =
License超配额熔断
10- LICENSE_CODE_AGENT_SUSPENDED =
License 响应码定义
4113- LICENSE_CODE_OVER_QUOTA =
Agent暂停
4114- LICENSE_CODE_EXPIRED =
License超配额
4116- LICENSE_CODE_INTERFACE_ERROR =
License过期
4120
Constants included from Workers::Polling
Workers::Polling::DEFAULT_SHUTDOWN_TIMEOUT
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
License接口异常.
Attributes inherited from Worker
Instance Method Summary collapse
-
#initialize(client:, logger:, probe_state:, **options) ⇒ LicenseWorker
constructor
A new instance of LicenseWorker.
- #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) ⇒ LicenseWorker
Returns a new instance of LicenseWorker.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/datadog/core/cloudwise/license_worker.rb', line 40 def initialize(client:, logger:, probe_state:, **) @client = client @logger = logger @probe_state = probe_state @failure_count = 0 @last_fuse_state = nil # 记录最后一次的熔断状态 @last_fuse_describe = nil # 记录最后一次的熔断描述 # 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)
License接口异常
38 39 40 |
# File 'lib/datadog/core/cloudwise/license_worker.rb', line 38 def client @client end |
Instance Method Details
#perform ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/datadog/core/cloudwise/license_worker.rb', line 57 def perform # Wait for Host ID to be generated unless client.account_id Cloudwise.log_debug { 'Cloudwise: Waiting for Host ID generation before license verification' } return true end Cloudwise.log_debug { 'Cloudwise: Verifying license' } result = client.verify_license process_license_result(result) true rescue => e Cloudwise.log_error { "Cloudwise: License worker error: #{e.class.name} #{e.message}" } handle_license_failure true # Continue running end |
#start ⇒ Object
Public method to start the worker
78 79 80 81 82 83 |
# File 'lib/datadog/core/cloudwise/license_worker.rb', line 78 def start return false if !enabled? || started? # Start the async worker thread perform end |