Sha256: fabfc7a137ae10258fe1626fce9f7373050b801edb74938c0534e2a2b72980d6
Contents?: true
Size: 1.17 KB
Versions: 16
Compression:
Stored size: 1.17 KB
Contents
module NulogyMessageBusProducer module Subscriptions # A facade to find subscriptions. # # It will retrieve subscriptions from these sources: # - configured subscriptions via #add_subscription! # - self-serve subscriptions via GraphQL API # # If a subscription exists with the same id in both sources, then # the configured subscription will be returned. class Finder def initialize(config) @config = config end # Note: raises like ActiveRecord#find def find(id) @config.configured_subscriptions.detect { |s| s.id == id } || SelfServeSubscription.find(id) end def for_schema_event(schema_key, event_type) subscriptions = configured(schema_key, event_type) + self_serve(schema_key, event_type) subscriptions.uniq(&:id) end private def self_serve(schema_key, event_type) SelfServeSubscription.where(event_type: event_type, schema_key: schema_key) end def configured(schema_key, event_type) @config .configured_subscriptions .filter { |s| s.event_type == event_type && s.schema_key == schema_key } end end end end
Version data entries
16 entries across 16 versions & 1 rubygems