Sha256: ddb0d8aebb6b4a9f9f910f8b75a491e74a12fb6dcd66a24cab35c3ea35803d86

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module Karafka
  module Processing
    # Our processing patterns differ depending on various features configurations
    # In this namespace we collect strategies for particular feature combinations to simplify the
    # design. Based on features combinations we can then select handling strategy for a given case.
    #
    # @note The lack of common code here is intentional. It would get complex if there would be
    #   any type of composition, so each strategy is expected to be self-sufficient
    module Strategies
      # Base strategy that should be included in each strategy, just to ensure the API
      module Base
        # What should happen before jobs are enqueued
        # @note This runs from the listener thread, not recommended to put anything slow here
        def handle_before_enqueue
          raise NotImplementedError, 'Implement in a subclass'
        end

        # What should happen before we kick in the processing
        def handle_before_consume
          raise NotImplementedError, 'Implement in a subclass'
        end

        # What should happen in the processing
        def handle_consume
          raise NotImplementedError, 'Implement in a subclass'
        end

        # Post-consumption handling
        def handle_after_consume
          raise NotImplementedError, 'Implement in a subclass'
        end

        # Revocation handling
        def handle_revoked
          raise NotImplementedError, 'Implement in a subclass'
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
karafka-2.0.24 lib/karafka/processing/strategies/base.rb
karafka-2.0.23 lib/karafka/processing/strategies/base.rb
karafka-2.0.22 lib/karafka/processing/strategies/base.rb