Class: Dionysus::Consumer

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

Defined Under Namespace

Classes: BatchEventsPublisher, Config, Deserializer, DionysusEvent, KarafkaConsumerGenerator, ParamsBatchProcessor, ParamsBatchTransformations, Persistor, Registry, SyncedData, SynchronizableModel, WorkersGroup

Class Method Summary collapse

Class Method Details

.configurationObject



4
5
6
# File 'lib/dionysus/consumer.rb', line 4

def self.configuration
  @configuration ||= Dionysus::Consumer::Config.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



8
9
10
# File 'lib/dionysus/consumer.rb', line 8

def self.configure
  yield configuration
end

.declare(&config) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/dionysus/consumer.rb', line 16

def self.declare(&config)
  registry = Dionysus::Consumer::Registry.new
  registry.instance_eval(&config)

  Dionysus.inject_routing!(registry)

  configure do |configuration|
    configuration.registry = registry
  end
end

.registryObject



12
13
14
# File 'lib/dionysus/consumer.rb', line 12

def self.registry
  configuration.registry
end

.reset!Object



27
28
29
30
31
32
33
34
35
# File 'lib/dionysus/consumer.rb', line 27

def self.reset!
  return if registry.nil?

  registry.registrations.values.flat_map(&:consumers).each do |consumer_class|
    Dionysus.send(:remove_const, consumer_class.name.demodulize.to_sym) if consumer_class.name
  end
  @configuration = nil
  Dionysus.inject_routing!(nil)
end