Sha256: 79e750c305ac4464b0ed5c2a6220865bc1987248dd6b8e3211c06790166155c9
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 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 # 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 self.encode(params_batch) Base64.encode64(Marshal.dump(params_batch.to_a)) 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 self.decode(params_string) Marshal.load(Base64.decode64(params_string)) end end # rubocop:enable Security/MarshalLoad end end
Version data entries
5 entries across 5 versions & 1 rubygems