Class: FiberAudit::Runtime::OperationLivenessPolicy
- Inherits:
-
Data
- Object
- Data
- FiberAudit::Runtime::OperationLivenessPolicy
- Defined in:
- lib/fiber_audit/runtime/operation_liveness_policy.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#long_active_threshold_ms ⇒ Object
readonly
Returns the value of attribute long_active_threshold_ms.
-
#poll_interval_ms ⇒ Object
readonly
Returns the value of attribute poll_interval_ms.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(**values) ⇒ OperationLivenessPolicy
constructor
A new instance of OperationLivenessPolicy.
- #long_active?(age_ns:) ⇒ Boolean
- #long_active_threshold_ns ⇒ Object
- #poll_interval_ns ⇒ Object
Constructor Details
#initialize(**values) ⇒ OperationLivenessPolicy
Returns a new instance of OperationLivenessPolicy.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 8 def initialize(**values) unknown = values.keys - OperationLivenessPolicy::DEFAULTS.keys raise RuntimeContractError, "unknown operation liveness policy field: #{unknown.first}" unless unknown.empty? fields = OperationLivenessPolicy::DEFAULTS.merge(values) raise RuntimeContractError, 'enabled must be a Boolean' unless [true, false].include?(fields[:enabled]) limits = OperationLivenessPolicy::LIMITS.to_h do |name, range| value = fields.fetch(name) unless value.is_a?(Integer) && range.cover?(value) raise RuntimeContractError, "#{name} must be an Integer in #{range}" end [name, value] end super(enabled: fields[:enabled], **limits) end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled
7 8 9 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 7 def enabled @enabled end |
#long_active_threshold_ms ⇒ Object (readonly)
Returns the value of attribute long_active_threshold_ms
7 8 9 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 7 def long_active_threshold_ms @long_active_threshold_ms end |
#poll_interval_ms ⇒ Object (readonly)
Returns the value of attribute poll_interval_ms
7 8 9 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 7 def poll_interval_ms @poll_interval_ms end |
Instance Method Details
#enabled? ⇒ Boolean
26 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 26 def enabled? = enabled |
#long_active?(age_ns:) ⇒ Boolean
30 31 32 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 30 def long_active?(age_ns:) Validation.integer(age_ns, 'active operation age') > long_active_threshold_ns end |
#long_active_threshold_ns ⇒ Object
28 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 28 def long_active_threshold_ns = long_active_threshold_ms * OperationLivenessPolicy::NANOSECONDS_PER_MILLISECOND |
#poll_interval_ns ⇒ Object
27 |
# File 'lib/fiber_audit/runtime/operation_liveness_policy.rb', line 27 def poll_interval_ns = poll_interval_ms * OperationLivenessPolicy::NANOSECONDS_PER_MILLISECOND |