lib/avromatic/messaging.rb in avromatic-2.2.6 vs lib/avromatic/messaging.rb in avromatic-2.3.0

- old
+ new

@@ -27,11 +27,12 @@ schema_json = @registry.fetch(schema_id) @schemas_by_id[schema_id] = Avro::Schema.parse(schema_json) end # The following line differs from the parent class to use a custom DatumReader - reader = Avromatic::IO::DatumReader.new(writers_schema, readers_schema) + reader_class = Avromatic.use_custom_datum_reader ? Avromatic::IO::DatumReader : Avro::IO::DatumReader + reader = reader_class.new(writers_schema, readers_schema) reader.read(decoder) end def encode(message, schema_name: nil, namespace: @namespace, subject: nil) schema = @schema_store.find(schema_name, namespace) @@ -48,10 +49,11 @@ # The schema id is encoded as a 4-byte big-endian integer. encoder.write([schema_id].pack('N')) # The following line differs from the parent class to use a custom DatumWriter - writer = Avromatic::IO::DatumWriter.new(schema) + writer_class = Avromatic.use_custom_datum_writer ? Avromatic::IO::DatumWriter : Avro::IO::DatumWriter + writer = writer_class.new(schema) # The actual message comes last. writer.write(message, encoder) stream.string