Class: Application

Inherits:
Object
  • Object
show all
Includes:
RKS::Support::Configurable
Defined in:
lib/rks/application.rb

Class Method Summary collapse

Methods included from RKS::Support::Concern

#included

Class Method Details

.avro_registryObject



13
14
15
16
17
18
# File 'lib/rks/application.rb', line 13

def avro_registry
  @avro ||= AvroTurf::Messaging.new(
    schemas_path: "./app/schemas",
    registry_url: Application.config.avro_registry_url
  )
end

.loggerObject



9
10
11
# File 'lib/rks/application.rb', line 9

def logger
  @logger ||= RKS::Logger.init
end

.runObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rks/application.rb', line 20

def run
  Application.logger.info message: "Application started"
  
  RKS::Event::Handler.router.routes.keys.each do |event_name|
    topic = [config.env,event_name].join("-")
    Kafka.consumer.subscribe(topic)
  end
  # This will loop indefinitely, yielding each message in turn.
  Kafka.consumer.each_message do |message|
    RKS::Event::Processor.process(correlation_id: message.key, event: sanitized_event_name(message.topic), payload: message.value)
  end
end

.sanitized_event_name(topic) ⇒ Object



33
34
35
# File 'lib/rks/application.rb', line 33

def sanitized_event_name(topic)
  topic.gsub("#{config.env}-", "")
end