Class: Igniter::Store::Protocol::SyncProfile
- Inherits:
-
Struct
- Object
- Struct
- Igniter::Store::Protocol::SyncProfile
- Defined in:
- lib/igniter/store/protocol/sync_profile.rb
Overview
OP4 — Sync Hub Profile value object.
A SyncProfile is a point-in-time package that carries everything a durable hub needs to synchronize with the live store:
descriptors — full metadata_snapshot (OP2)
facts — serialized fact packets (full or incremental)
retention — retention policy snapshot
compaction_receipts — compaction history
cursor — watermark for next incremental sync
subscription_checkpoints — last-delivered position per subscription (OP4+)
Cursor:
nil — this is a fresh full snapshot (hub has never synced)
{ kind: :timestamp, value: Float } — resume from this timestamp
A hub stores the cursor locally. On the next sync request it sends cursor: back and receives only facts written since that timestamp.
Instance Attribute Summary collapse
-
#compaction_activity ⇒ Object
Returns the value of attribute compaction_activity.
-
#compaction_receipts ⇒ Object
Returns the value of attribute compaction_receipts.
-
#cursor ⇒ Object
Returns the value of attribute cursor.
-
#descriptors ⇒ Object
Returns the value of attribute descriptors.
-
#facts ⇒ Object
Returns the value of attribute facts.
-
#generated_at ⇒ Object
Returns the value of attribute generated_at.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#retention ⇒ Object
Returns the value of attribute retention.
-
#schema_version ⇒ Object
Returns the value of attribute schema_version.
-
#subscription_checkpoints ⇒ Object
Returns the value of attribute subscription_checkpoints.
Instance Method Summary collapse
- #fact_count ⇒ Object
- #full? ⇒ Boolean
- #incremental? ⇒ Boolean
-
#next_cursor ⇒ Object
Build the cursor that a hub should send on its next sync request.
- #to_json(*opts) ⇒ Object
Instance Attribute Details
#compaction_activity ⇒ Object
Returns the value of attribute compaction_activity
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def compaction_activity @compaction_activity end |
#compaction_receipts ⇒ Object
Returns the value of attribute compaction_receipts
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def compaction_receipts @compaction_receipts end |
#cursor ⇒ Object
Returns the value of attribute cursor
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def cursor @cursor end |
#descriptors ⇒ Object
Returns the value of attribute descriptors
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def descriptors @descriptors end |
#facts ⇒ Object
Returns the value of attribute facts
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def facts @facts end |
#generated_at ⇒ Object
Returns the value of attribute generated_at
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def generated_at @generated_at end |
#kind ⇒ Object
Returns the value of attribute kind
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def kind @kind end |
#retention ⇒ Object
Returns the value of attribute retention
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def retention @retention end |
#schema_version ⇒ Object
Returns the value of attribute schema_version
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def schema_version @schema_version end |
#subscription_checkpoints ⇒ Object
Returns the value of attribute subscription_checkpoints
24 25 26 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 24 def subscription_checkpoints @subscription_checkpoints end |
Instance Method Details
#fact_count ⇒ Object
39 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 39 def fact_count = facts.size |
#full? ⇒ Boolean
37 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 37 def full? = cursor.nil? |
#incremental? ⇒ Boolean
38 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 38 def incremental? = !full? |
#next_cursor ⇒ Object
Build the cursor that a hub should send on its next sync request.
44 45 46 47 48 49 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 44 def next_cursor return nil if facts.empty? latest_ts = facts.max_by { |f| f[:transaction_time] || f[:timestamp] } .then { |f| f[:transaction_time] || f[:timestamp] } { kind: :timestamp, value: latest_ts } end |
#to_json(*opts) ⇒ Object
41 |
# File 'lib/igniter/store/protocol/sync_profile.rb', line 41 def to_json(*opts) = to_h.to_json(*opts) |