Class: Hatchet::EvictionPolicy
- Inherits:
-
Object
- Object
- Hatchet::EvictionPolicy
- Defined in:
- lib/hatchet/eviction_policy.rb
Overview
Task-scoped eviction parameters for durable tasks.
Setting the durable task’s eviction policy to “nil“ means the task run is never eligible for eviction.
Instance Attribute Summary collapse
-
#allow_capacity_eviction ⇒ Boolean
readonly
Whether this task may be evicted under durable-slot pressure.
-
#priority ⇒ Integer
readonly
Lower values are evicted first when multiple candidates exist.
-
#ttl ⇒ Numeric?
readonly
Maximum continuous waiting duration in seconds before TTL-eligible eviction.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(ttl:, allow_capacity_eviction: true, priority: 0) ⇒ EvictionPolicy
constructor
A new instance of EvictionPolicy.
Constructor Details
#initialize(ttl:, allow_capacity_eviction: true, priority: 0) ⇒ EvictionPolicy
Returns a new instance of EvictionPolicy.
31 32 33 34 35 36 |
# File 'lib/hatchet/eviction_policy.rb', line 31 def initialize(ttl:, allow_capacity_eviction: true, priority: 0) @ttl = ttl @allow_capacity_eviction = allow_capacity_eviction @priority = priority freeze end |
Instance Attribute Details
#allow_capacity_eviction ⇒ Boolean (readonly)
Returns Whether this task may be evicted under durable-slot pressure.
23 24 25 |
# File 'lib/hatchet/eviction_policy.rb', line 23 def allow_capacity_eviction @allow_capacity_eviction end |
#priority ⇒ Integer (readonly)
Returns Lower values are evicted first when multiple candidates exist.
26 27 28 |
# File 'lib/hatchet/eviction_policy.rb', line 26 def priority @priority end |
#ttl ⇒ Numeric? (readonly)
Returns Maximum continuous waiting duration in seconds before TTL-eligible eviction. Applies to time spent in SDK-instrumented “waiting” states (e.g. :meth:‘DurableContext#sleep_for`, :meth:`DurableContext#wait_for`). “nil“ disables TTL eviction.
20 21 22 |
# File 'lib/hatchet/eviction_policy.rb', line 20 def ttl @ttl end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
38 39 40 41 42 43 |
# File 'lib/hatchet/eviction_policy.rb', line 38 def ==(other) other.is_a?(EvictionPolicy) && other.ttl == ttl && other.allow_capacity_eviction == allow_capacity_eviction && other.priority == priority end |
#hash ⇒ Object
46 47 48 |
# File 'lib/hatchet/eviction_policy.rb', line 46 def hash [self.class, ttl, allow_capacity_eviction, priority].hash end |