Class: Rimless::Karafka::Base64Interchanger
- Inherits:
-
Karafka::Interchanger
- Object
- Karafka::Interchanger
- Rimless::Karafka::Base64Interchanger
- Defined in:
- lib/rimless/karafka/base64_interchanger.rb
Overview
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
Instance Method Summary collapse
-
#decode(params_batch) ⇒ Array<Hash>
Decode the binary Apache Kafka message(s) so they can be processed by the Sidekiq
Rimless::ConsumerJob
. -
#encode(params_batch) ⇒ String
Encode a binary Apache Kafka message(s) so they can be passed to the Sidekiq
Rimless::ConsumerJob
.
Instance Method Details
#decode(params_batch) ⇒ Array<Hash>
Decode the binary Apache Kafka message(s) so they can be processed by the Sidekiq Rimless::ConsumerJob
.
26 27 28 |
# File 'lib/rimless/karafka/base64_interchanger.rb', line 26 def decode(params_batch) super(Marshal.load(Base64.decode64(params_batch))).map(&:stringify_keys) end |
#encode(params_batch) ⇒ String
Encode a binary Apache Kafka message(s) so they can be passed to the Sidekiq Rimless::ConsumerJob
.
17 18 19 |
# File 'lib/rimless/karafka/base64_interchanger.rb', line 17 def encode(params_batch) Base64.encode64(Marshal.dump(super)) end |