Sha256: 30062702370c46b76f3cf4d961f4cebf7482dd015346a857384af90d0c6b7d98

Contents?: true

Size: 1.1 KB

Versions: 17

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Rimless
  module Karafka
    # Allow the +karafka-sidekiq-backend+ gem to transfer binary Apache Kafka
    # messages to the actual Sidekiq job.
    #
    # rubocop:disable Security/MarshalLoad because we encode/decode the
    #   messages in our own controlled context
    class Base64Interchanger < ::Karafka::Interchanger
      # Encode a binary Apache Kafka message(s) so they can be passed to the
      # Sidekiq +Rimless::ConsumerJob+.
      #
      # @param params_batch [Mixed] the raw message(s) to encode
      # @return [String] the marshaled+base64 encoded data
      def encode(params_batch)
        Base64.encode64(Marshal.dump(super))
      end

      # Decode the binary Apache Kafka message(s) so they can be processed by
      # the Sidekiq +Rimless::ConsumerJob+.
      #
      # @param params_string [String] the marshaled+base64 encoded data
      # @return [Mixed] the unmarshaled+base64 decoded data
      def decode(params_string)
        Marshal.load(Base64.decode64(super)).map(&:stringify_keys)
      end
    end
    # rubocop:enable Security/MarshalLoad
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rimless-1.7.6 lib/rimless/karafka/base64_interchanger.rb
rimless-1.7.5 lib/rimless/karafka/base64_interchanger.rb
rimless-1.7.4 lib/rimless/karafka/base64_interchanger.rb
rimless-1.7.3 lib/rimless/karafka/base64_interchanger.rb
rimless-1.7.2 lib/rimless/karafka/base64_interchanger.rb
rimless-1.7.1 lib/rimless/karafka/base64_interchanger.rb
rimless-1.7.0 lib/rimless/karafka/base64_interchanger.rb
rimless-1.6.0 lib/rimless/karafka/base64_interchanger.rb
rimless-1.5.1 lib/rimless/karafka/base64_interchanger.rb
rimless-1.5.0 lib/rimless/karafka/base64_interchanger.rb
rimless-1.4.2 lib/rimless/karafka/base64_interchanger.rb
rimless-1.4.1 lib/rimless/karafka/base64_interchanger.rb
rimless-1.4.0 lib/rimless/karafka/base64_interchanger.rb
rimless-1.3.0 lib/rimless/karafka/base64_interchanger.rb
rimless-1.2.0 lib/rimless/karafka/base64_interchanger.rb
rimless-1.1.1 lib/rimless/karafka/base64_interchanger.rb
rimless-1.1.0 lib/rimless/karafka/base64_interchanger.rb