Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If not transactional use lower ack level for web-ui reporting in producer #342

Open
mensfeld opened this issue May 28, 2024 · 1 comment
Assignees

Comments

@mensfeld
Copy link
Member

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.

@mensfeld mensfeld self-assigned this May 28, 2024
@mensfeld
Copy link
Member Author

# 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant