Class: Dionysus::Producer::Registry::Registration

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/producer/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/producer/registry.rb', line 24

def initialize(namespace)
  @namespace = namespace
  @topics = []
  @serializer_klass = nil
  @producers = []
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



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

def namespace
  @namespace
end

#producersObject (readonly)

Returns the value of attribute producers.



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

def producers
  @producers
end

#serializer_klassObject (readonly)

Returns the value of attribute serializer_klass.



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

def serializer_klass
  @serializer_klass
end

#topicsObject (readonly)

Returns the value of attribute topics.



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

def topics
  @topics
end

Instance Method Details

#serializer(serializer_klass) ⇒ Object



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

def serializer(serializer_klass)
  @serializer_klass = serializer_klass
end

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



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

def topic(name, options = {}, &block)
  new_topic = Topic.new(namespace, name, serializer_klass, options)
  new_topic.instance_eval(&block)
  producer = Dionysus::Producer::KarafkaResponderGenerator.new.generate(
    Dionysus::Producer.configuration, new_topic
  )
  producers << producer
  new_topic.producer = producer
  topics << new_topic
end