Class: Dionysus::Consumer::Registry::Registration

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/consumer/registry.rb

Defined Under Namespace

Classes: Topic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace) ⇒ Registration

Returns a new instance of Registration.



24
25
26
27
28
29
# File 'lib/dionysus/consumer/registry.rb', line 24

def initialize(namespace)
  @namespace = namespace
  @topics = []
  @deserializer_klass = nil
  @consumers = []
end

Instance Attribute Details

#consumersObject (readonly)

Returns the value of attribute consumers.



22
23
24
# File 'lib/dionysus/consumer/registry.rb', line 22

def consumers
  @consumers
end

#deserializer_klassObject (readonly)

Returns the value of attribute deserializer_klass.



22
23
24
# File 'lib/dionysus/consumer/registry.rb', line 22

def deserializer_klass
  @deserializer_klass
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



22
23
24
# File 'lib/dionysus/consumer/registry.rb', line 22

def namespace
  @namespace
end

#topicsObject (readonly)

Returns the value of attribute topics.



22
23
24
# File 'lib/dionysus/consumer/registry.rb', line 22

def topics
  @topics
end

Instance Method Details

#deserializer(deserializer_klass) ⇒ Object



31
32
33
# File 'lib/dionysus/consumer/registry.rb', line 31

def deserializer(deserializer_klass)
  @deserializer_klass = deserializer_klass
end

#topic(name, options = {}, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/dionysus/consumer/registry.rb', line 35

def topic(name, options = {}, &block)
  new_topic = Topic.new(namespace, name, deserializer_klass, options, &block)
  consumer = Dionysus::Consumer::KarafkaConsumerGenerator.new.generate(
    Dionysus::Consumer.configuration, new_topic
  )
  consumers << consumer
  new_topic.consumer = consumer
  topics << new_topic
end