Class: Upkeep::Subscriptions::BaseStore
- Inherits:
-
Object
- Object
- Upkeep::Subscriptions::BaseStore
- Defined in:
- lib/upkeep/subscriptions/base_store.rb
Overview
Shared pending -> active registry choreography for the in-memory and Active Record stores. Subclasses hold the @pending_registry / @active_registry instances and supply their store-specific tails through the documented hooks.
Direct Known Subclasses
Constant Summary collapse
- TRIM_EVERY =
Opportunistic trim (Solid Cache/Solid Cable style): every TRIM_EVERY registrations the store deletes at most TRIM_BATCH_LIMIT subscriptions older than the configured subscription TTL. A deterministic counter is used instead of rand so the cadence is reproducible in tests.
100- TRIM_BATCH_LIMIT =
500- PRUNE_NOTIFICATION =
"prune.upkeep"- DEFAULT_SUBSCRIPTION_TTL =
24 * 60 * 60
Instance Method Summary collapse
- #explain(id) ⇒ Object
- #fetch(id) ⇒ Object
- #touch(id, now: Time.now) ⇒ Object
- #unregister(ids) ⇒ Object
Instance Method Details
#explain(id) ⇒ Object
42 43 44 |
# File 'lib/upkeep/subscriptions/base_store.rb', line 42 def explain(id) fetch(id).explain end |
#fetch(id) ⇒ Object
38 39 40 |
# File 'lib/upkeep/subscriptions/base_store.rb', line 38 def fetch(id) active_registry.fetch(id) || pending_registry.fetch(id) || fetch_missing(id) end |
#touch(id, now: Time.now) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/upkeep/subscriptions/base_store.rb', line 21 def touch(id, now: Time.now) fetch(id) = { "last_seen_at" => now.utc.iso8601 } pending_registry.touch(id, metadata: ) active_registry.touch(id, metadata: ) after_touch(id, metadata: , now: now) end |
#unregister(ids) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/upkeep/subscriptions/base_store.rb', line 29 def unregister(ids) ids = Array(ids) before_unregister(ids) pending_registry.unregister(ids) active_registry.unregister(ids) after_unregister(ids) ids.size end |