-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathkarafka.rb
62 lines (50 loc) · 2.27 KB
/
karafka.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true
class KarafkaApp < Karafka::App
setup do |config|
config.kafka = {
"bootstrap.servers": ENV["LAGO_KAFKA_BOOTSTRAP_SERVERS"]
}
if ENV["LAGO_KAFKA_SECURITY_PROTOCOL"].present?
config.kafka = config.kafka.merge({"security.protocol": ENV["LAGO_KAFKA_SECURITY_PROTOCOL"]})
end
if ENV["LAGO_KAFKA_SASL_MECHANISMS"].present?
config.kafka = config.kafka.merge({"sasl.mechanisms": ENV["LAGO_KAFKA_SASL_MECHANISMS"]})
end
if ENV["LAGO_KAFKA_USERNAME"].present?
config.kafka = config.kafka.merge({"sasl.username": ENV["LAGO_KAFKA_USERNAME"]})
end
if ENV["LAGO_KAFKA_PASSWORD"].present?
config.kafka = config.kafka.merge({"sasl.password": ENV["LAGO_KAFKA_PASSWORD"]})
end
config.client_id = "Lago"
# Recreate consumers with each batch. This will allow Rails code reload to work in the
# development mode. Otherwise Karafka process would not be aware of code changes
config.consumer_persistence = !Rails.env.development?
end
# Comment out this part if you are not using instrumentation and/or you are not
# interested in logging events for certain environments. Since instrumentation
# notifications add extra boilerplate, if you want to achieve max performance,
# listen to only what you really need for given environment.
Karafka.monitor.subscribe(Karafka::Instrumentation::LoggerListener.new)
# Karafka.monitor.subscribe(Karafka::Instrumentation::ProctitleListener.new)
# This logger prints the producer development info using the Karafka logger.
# It is similar to the consumer logger listener but producer oriented.
Karafka.producer.monitor.subscribe(
WaterDrop::Instrumentation::LoggerListener.new(
# Log producer operations using the Karafka logger
Karafka.logger,
# If you set this to true, logs will contain each message details
# Please note, that this can be extensive
log_messages: false
)
)
end
Karafka::Web.setup do |config|
# Set this to false in all apps except one
config.processing.active = false
if ENV["LAGO_KARAFKA_WEB_USERNAME"].present?
config.ui.sessions.secret = ENV["LAGO_KARAFKA_WEB_SECRET"]
end
end
Karafka::Web.enable! if ENV["LAGO_KARAFKA_WEB"]
Karafka::Process.tags.add(:application_name, "lago-api")