LGouellec / kafka-streams-dotnet

.NET Stream Processing Library for Apache Kafka 🚀
https://lgouellec.github.io/kafka-streams-dotnet/
MIT License
453 stars 73 forks source link

StreamConfig initialization with options pattern #265

Closed ppilev closed 1 year ago

ppilev commented 1 year ago

Description
This change will allow configuration settings used to initialize instances of ClientConfig, ConsumerConfig and ProducerConfig to be reused for StreamConfig initialization.

Changes

Problem Details Currently StreamConfig is derived from Dictionary<string, dynamic> thus during the instance initialization the public property setters are ignored, the configuration values are stored directly into the base class (the dictionary) and the type conversion (i.e. for enum values) is not handled properly, i.e. consider the following configuration in appsettings.json file:

{
  "Kafka": {
    "ConsumerConfig": {
      "AutoOffsetReset": "Error"
    }
  }
}

when applied through options pattern this configuration won't initialize config.AutoOffsetReset property with Error but just will create the following entry in the underlying dictionary, however such entry has no meaning to StreamConfig at all

{ "AutoOffsetReset", "Error" }

Expected behavior For expected behavior please follow the implementation of CreateStreamConfigThroughOptionsPattern test from this PR.