Class: Textus::Domain::Policy::Lifecycle
- Inherits:
-
Object
- Object
- Textus::Domain::Policy::Lifecycle
- Defined in:
- lib/textus/domain/policy/lifecycle.rb
Overview
Unified per-entry lifecycle policy (ADR 0079): one ttl + one action. Replaces the separate Fetch (ttl/on_stale) and Retention (expire_after/archive_after) policies. The action’s destructiveness decides WHERE it runs: lazy actions (refresh/warn) on get/list reads; destructive actions (drop/archive) only on the tend sweep.
Constant Summary collapse
- LAZY =
%i[refresh warn].freeze
- DESTRUCTIVE =
%i[drop archive].freeze
- ALLOWED =
(LAZY + DESTRUCTIVE).freeze
Instance Attribute Summary collapse
-
#budget_ms ⇒ Object
readonly
Returns the value of attribute budget_ms.
-
#on_expire ⇒ Object
readonly
Returns the value of attribute on_expire.
Instance Method Summary collapse
- #destructive? ⇒ Boolean
-
#initialize(ttl:, on_expire:, budget_ms: nil) ⇒ Lifecycle
constructor
A new instance of Lifecycle.
- #lazy? ⇒ Boolean
- #ttl_seconds ⇒ Object
Constructor Details
#initialize(ttl:, on_expire:, budget_ms: nil) ⇒ Lifecycle
Returns a new instance of Lifecycle.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/textus/domain/policy/lifecycle.rb', line 16 def initialize(ttl:, on_expire:, budget_ms: nil) action = on_expire.is_a?(Symbol) ? on_expire : on_expire.to_s.to_sym unless ALLOWED.include?(action) raise Textus::UsageError.new( "lifecycle on_expire must be one of #{ALLOWED.join("|")}, got #{on_expire.inspect}", ) end @ttl = ttl @on_expire = action @budget_ms = budget_ms end |
Instance Attribute Details
#budget_ms ⇒ Object (readonly)
Returns the value of attribute budget_ms.
14 15 16 |
# File 'lib/textus/domain/policy/lifecycle.rb', line 14 def budget_ms @budget_ms end |
#on_expire ⇒ Object (readonly)
Returns the value of attribute on_expire.
14 15 16 |
# File 'lib/textus/domain/policy/lifecycle.rb', line 14 def on_expire @on_expire end |
Instance Method Details
#destructive? ⇒ Boolean
30 |
# File 'lib/textus/domain/policy/lifecycle.rb', line 30 def destructive? = DESTRUCTIVE.include?(@on_expire) |
#lazy? ⇒ Boolean
31 |
# File 'lib/textus/domain/policy/lifecycle.rb', line 31 def lazy? = LAZY.include?(@on_expire) |