Sha256: 58ad664f568031b2543143ad2066c4e789893da5ee0598c6bf912c29b1b05fad

Contents?: true

Size: 779 Bytes

Versions: 19

Compression:

Stored size: 779 Bytes

Contents

# frozen_string_literal: true

require "google/protobuf"

module Sbmt
  module KafkaConsumer
    module Serialization
      class ProtobufDeserializer < BaseDeserializer
        attr_reader :message_decoder

        def initialize(message_decoder_klass:, skip_decoding_error: false)
          super(skip_decoding_error: skip_decoding_error)

          @message_decoder = message_decoder_klass.constantize
        end

        def call(message)
          message_decoder.decode(message.raw_payload)
        rescue Google::Protobuf::ParseError, ArgumentError => e
          raise Sbmt::KafkaConsumer::SkipUndeserializableMessage, "cannot decode message: #{e.message}, payload: #{message.raw_payload}" if skip_decoding_error

          raise
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
sbmt-kafka_consumer-3.3.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-3.2.2 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-3.2.1 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-3.2.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-3.1.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.8.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-3.0.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.7.1 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.7.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.6.1 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.6.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.5.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.4.1 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.4.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.3.1 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.3.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.2.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.1.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb
sbmt-kafka_consumer-2.0.0 lib/sbmt/kafka_consumer/serialization/protobuf_deserializer.rb