Class: Upkeep::Subscriptions::Registrar

Inherits:
Object
  • Object
show all
Defined in:
lib/upkeep/subscriptions/registrar.rb

Defined Under Namespace

Classes: Registration

Instance Method Summary collapse

Constructor Details

#initialize(store:, shape_cache: ShapeCache.new) ⇒ Registrar

Returns a new instance of Registrar.



10
11
12
13
# File 'lib/upkeep/subscriptions/registrar.rb', line 10

def initialize(store:, shape_cache: ShapeCache.new)
  @store = store
  @shape_cache = shape_cache
end

Instance Method Details

#register(identity:, decision:, recorder:, metadata: {}, signature: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/upkeep/subscriptions/registrar.rb', line 15

def register(identity:, decision:, recorder:, metadata: {}, signature: nil)
  shape = shape_cache.resolve(recorder: recorder, decision: decision, signature: signature)
  subscription = store.register(
    subscriber_id: identity.subscriber_id,
    recorder: recorder,
    metadata: .merge(
      shared_stream_names: shape.shared_stream_names,
      subscription_shape_key: shape.key,
      subscription_shape_cache: shape.cache_state
    ).compact,
    entries: shape.entries
  )

  Registration.new(identity, decision, subscription, shape)
end