Open mensfeld opened 1 month ago
# frozen_string_literal: true
module Karafka
module Web
class Producer < SimpleDelegator
def initialize
@initialized = false
end
def __getobj__
unless @initialized
@delegate_sd_obj = build_producer
@initialized = true
end
super
end
private
def build_producer
default = ::Karafka.producer
return default if default.idempotent?
return default if default.transactional?
default.variant(topic_config: { acks: 0 })
end
end
end
end
Users usually may want to have stronger delivery warranties in their producers for their setup. We do not need this level of warranties in web UI because it's not mission critical and more analytics. That's why ack 1 should be ok to work with.