Sha256: e26374d06b25119a3d1e8ebdc88699ec540a9f312d468396a71db206200f7ff5

Contents?: true

Size: 920 Bytes

Versions: 34

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

module Karafka
  module Processing
    # A simple object that allows us to keep track of processing state.
    # It allows to indicate if given thing moved from success to a failure or the other way around
    # Useful for tracking consumption state
    class Result
      attr_reader :cause

      def initialize
        @success = true
        @cause = false
      end

      # @return [Boolean]
      def success?
        @success
      end

      # Marks state as successful
      def success!
        @success = true
        # We set cause to false so the previous error that occurred does not leak when error is
        # no longer present
        @cause = false
      end

      # Marks state as failure
      # @param cause [StandardError] error that occurred and caused failure
      def failure!(cause)
        @success = false
        @cause = cause
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
karafka-2.0.38 lib/karafka/processing/result.rb
karafka-2.0.37 lib/karafka/processing/result.rb
karafka-2.0.36 lib/karafka/processing/result.rb
karafka-2.0.35 lib/karafka/processing/result.rb
karafka-2.0.34 lib/karafka/processing/result.rb
karafka-2.0.33 lib/karafka/processing/result.rb
karafka-2.0.32 lib/karafka/processing/result.rb
karafka-2.0.31 lib/karafka/processing/result.rb
karafka-2.0.30 lib/karafka/processing/result.rb
karafka-2.0.29 lib/karafka/processing/result.rb
karafka-2.0.28 lib/karafka/processing/result.rb
karafka-2.0.27 lib/karafka/processing/result.rb
karafka-2.0.26 lib/karafka/processing/result.rb
karafka-2.0.24 lib/karafka/processing/result.rb
karafka-2.0.23 lib/karafka/processing/result.rb
karafka-2.0.22 lib/karafka/processing/result.rb
karafka-2.0.21 lib/karafka/processing/result.rb
karafka-2.0.20 lib/karafka/processing/result.rb
karafka-2.0.19 lib/karafka/processing/result.rb
karafka-2.0.18 lib/karafka/processing/result.rb