Class: Rimless::Karafka::Base64Interchanger
- Inherits:
-
Object
- Object
- 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
Class Method Summary collapse
-
.decode(params_string) ⇒ Mixed
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.
Class Method Details
.decode(params_string) ⇒ Mixed
Decode the binary Apache Kafka message(s) so they can be processed by the Sidekiq Rimless::ConsumerJob.
25 26 27 |
# File 'lib/rimless/karafka/base64_interchanger.rb', line 25 def self.decode(params_string) Marshal.load(Base64.decode64(params_string)) end |
.encode(params_batch) ⇒ String
Encode a binary Apache Kafka message(s) so they can be passed to the Sidekiq Rimless::ConsumerJob.
16 17 18 |
# File 'lib/rimless/karafka/base64_interchanger.rb', line 16 def self.encode(params_batch) Base64.encode64(Marshal.dump(params_batch.to_a)) end |