Class: Textus::Domain::Policy::Refresh
- Inherits:
-
Object
- Object
- Textus::Domain::Policy::Refresh
- Defined in:
- lib/textus/domain/policy/refresh.rb
Constant Summary collapse
- ALLOWED_ON_STALE =
%i[warn sync timed_sync].freeze
Instance Attribute Summary collapse
-
#fetch_timeout_seconds ⇒ Object
readonly
Returns the value of attribute fetch_timeout_seconds.
-
#on_stale ⇒ Object
readonly
Returns the value of attribute on_stale.
-
#sync_budget_ms ⇒ Object
readonly
Returns the value of attribute sync_budget_ms.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
-
#initialize(ttl:, on_stale:, sync_budget_ms:, fetch_timeout_seconds: nil) ⇒ Refresh
constructor
A new instance of Refresh.
- #to_freshness_policy ⇒ Object
- #ttl_seconds ⇒ Object
Constructor Details
#initialize(ttl:, on_stale:, sync_budget_ms:, fetch_timeout_seconds: nil) ⇒ Refresh
Returns a new instance of Refresh.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/textus/domain/policy/refresh.rb', line 9 def initialize(ttl:, on_stale:, sync_budget_ms:, fetch_timeout_seconds: nil) on_stale_sym = on_stale.is_a?(Symbol) ? on_stale : on_stale.to_s.to_sym unless ALLOWED_ON_STALE.include?(on_stale_sym) raise Textus::UsageError.new( "on_stale must be one of #{ALLOWED_ON_STALE.join(", ")} (got #{on_stale.inspect})", ) end @ttl = ttl @on_stale = on_stale_sym @sync_budget_ms = sync_budget_ms @fetch_timeout_seconds = fetch_timeout_seconds end |
Instance Attribute Details
#fetch_timeout_seconds ⇒ Object (readonly)
Returns the value of attribute fetch_timeout_seconds.
7 8 9 |
# File 'lib/textus/domain/policy/refresh.rb', line 7 def fetch_timeout_seconds @fetch_timeout_seconds end |
#on_stale ⇒ Object (readonly)
Returns the value of attribute on_stale.
7 8 9 |
# File 'lib/textus/domain/policy/refresh.rb', line 7 def on_stale @on_stale end |
#sync_budget_ms ⇒ Object (readonly)
Returns the value of attribute sync_budget_ms.
7 8 9 |
# File 'lib/textus/domain/policy/refresh.rb', line 7 def sync_budget_ms @sync_budget_ms end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
7 8 9 |
# File 'lib/textus/domain/policy/refresh.rb', line 7 def ttl @ttl end |