@@ -14,7 +14,7 @@ namespace Confluent.Kafka.Serialization
1414 /// </summary>
1515 public class AvroSerdeProvider : IDisposable
1616 {
17- AvroSerdeProviderConfig config ;
17+ IEnumerable < KeyValuePair < string , string > > config ;
1818 ISchemaRegistryClient schemaRegistryClient ;
1919
2020 /// <summary>
@@ -23,14 +23,14 @@ public class AvroSerdeProvider : IDisposable
2323 /// <param name="config">
2424 /// Configuration properties.
2525 /// </param>
26- public AvroSerdeProvider ( AvroSerdeProviderConfig config )
26+ public AvroSerdeProvider ( IEnumerable < KeyValuePair < string , string > > config )
2727 {
2828 this . config = config ;
2929 schemaRegistryClient = new CachedSchemaRegistryClient ( config ) ;
3030 }
3131
3232 /// <summary>
33- /// Create a new avro deserializer. Use this deserializer with
33+ /// Create a new avro deserializer generator . Use this with
3434 /// GenericRecord, types generated using the avrogen.exe tool or
3535 /// one of the following primitive types: int, long, float,
3636 /// double, boolean, string, byte[].
@@ -41,46 +41,35 @@ public AvroSerdeProvider(AvroSerdeProviderConfig config)
4141 /// bytes 1-4: Unique global id of the avro schema that was used for encoding (as registered in Confluent Schema Registry), big endian.
4242 /// following bytes: The serialized data.
4343 /// </remarks>
44- public IDeserializer < T > CreateDeserializer < T > ( )
44+ public DeserializerGenerator < T > GetDeserializerGenerator < T > ( )
4545 {
46- var deserializer = new AvroDeserializer < T > ( schemaRegistryClient ) ;
47- deserializer . Configure ( config , false ) ;
48- return deserializer ;
46+ return ( forKey ) =>
47+ {
48+ var deserializer = new AvroDeserializer < T > ( schemaRegistryClient ) ;
49+ deserializer . Configure ( config , forKey ) ;
50+ return ( string topic , ReadOnlySpan < byte > data , bool isNull ) => deserializer . Deserialize ( topic , data , isNull ) ;
51+ } ;
4952 }
5053
5154 /// <summary>
52- /// Create a new avro serializer for message keys . Use this serializer
53- /// with GenericRecord, types generated using the avrogen.exe tool or
55+ /// Create a new avro serializer generator . Use this with
56+ /// GenericRecord, types generated using the avrogen.exe tool or
5457 /// one of the following primitive types: int, long, float, double,
5558 /// boolean, string, byte[].
5659 /// </summary>
57- public ISerializer < T > CreateKeySerializer < T > ( )
60+ public SerializerGenerator < T > GetSerializerGenerator < T > ( )
5861 {
59- var serializer = new AvroSerializer < T > ( schemaRegistryClient ) ;
60- serializer . Configure ( config , true ) ;
61- return serializer ;
62+ return ( forKey ) =>
63+ {
64+ var serializer = new AvroSerializer < T > ( schemaRegistryClient ) ;
65+ serializer . Configure ( config , true ) ;
66+ return ( string topic , T data ) => serializer . Serialize ( topic , data ) ;
67+ } ;
6268 }
6369
64- /// <summary>
65- /// Create a new avro serializer for message values. Use this serializer
66- /// with GenericRecord, types generated using the avrogen.exe tool or
67- /// one of the following primitive types: int, long, float, double,
68- /// boolean, string, byte[].
69- /// </summary>
70- public ISerializer < T > CreateValueSerializer < T > ( )
71- {
72- var serializer = new AvroSerializer < T > ( schemaRegistryClient ) ;
73- serializer . Configure ( config , false ) ;
74- return serializer ;
75- }
76-
7770 /// <summary>
7871 /// Releases all resources owned by this object.
7972 /// </summary>
80- public void Dispose ( )
81- {
82- schemaRegistryClient . Dispose ( ) ;
83- }
73+ public void Dispose ( ) => schemaRegistryClient . Dispose ( ) ;
8474 }
8575}
86-
0 commit comments