Replies: 3 comments
-
Is this proposal covering when we want to add configuration for an external (non Aiven) component, e.g. a custom record grouper like in #297? |
Beta Was this translation helpful? Give feedback.
-
Comment on the initial argument. We do not need to extend the Kafka SourceConnectorConfig, SinkConnectorConfig, or ConnectorConfig. We do need to extend the Kafka AbstractConfig class. But the design for components that are mixed in across hierarchies still applies. |
Beta Was this translation helpful? Give feedback.
-
You are swapping inheritance for composition, but requiring the caller to know of the composition, which isnt needed
change
Now you have the sources and sinks encapsulating all of the configuration access methods for all of the composed configuration fragments. You could probably move the whole of the config to the interface, as the definion looks to be just static methods, that way the composition is just by assembly of the interfaces ( and the config init/validate etc which would have to be explicit as we dont have a real trait mixin :-) ), but you still have to do this in the existing proposal I am not sure what the use case is for the fluent access to the common code fragment. IF thats needed then again it looks to require the caller to understand the composition, which I dont see a need for, and I think shoul dbe avoided. I dont know all of your code though .... |
Beta Was this translation helpful? Give feedback.
-
Problem Statement
We have a need to add configuration definitions to the system in general and in particular we need to be able to share configuration properties across the Source and Sink implementations. A problem arises because Kafka Connector framework defines two distinct base classes for Source (SourceConnectorConfig) and Sink (SinkConnectorConfig). These share a common Kafka Connector parent class (ConnectorConfig). These configuration use a ConfigDef object and modify it to create an internal representation of
ConfigDef
that is then used to answer any of the "getX()" methods (e.g.getInt(String key)
,get(String key)
, etc.). This means that theConfigDef
has to be constructed and inserted into the constructors for theSourceConnectorConfig
andSinkConnectorConfig
as any later changes to theConfigDef
will be ignored.In pull request #312 a set of configuration classes has been proposed. Under this proposal, if we look at a typical Source connector, for example S3 Source Connector we find the following Config hierarchy:
ConnectorConfig -> SourceConnectorConfig -> CommonSourceConfig -> S3SourceConfig
; whereCommonSourceConfig
andS3SourceConfig
is in our code base.A typical Sink connector has a Config hierarchy like:
ConnectorConfig -> SinkConnectorConfig -> CommonSinkConfig -> S3SinkConfig
. SimilarlyCommonSinkConfig
andS3SinkConfig
are in our code base.The problem arises for when
S3SinkConfig
andS3SourceConfig
need to share common property definitions and access methods.We need a mechanism that will:
ConfigDef
before the constructor is called.Proposed Solution
Create Configuration Fragments
The concept is that the shared configuration properties can be broken down in to logical fragments that handle single concept. Those fragments will provide the Configuration Properties and standard methods to extract data from the configuration.
This implementation must able to fit into#312 to create a shared connector configuration framework for the connectors in this repository.
As an example let's look at the
SinkCommonsConfig
from #312 which implements a hierarchy to be used across the connectors without requiring modification of all existing connectors while providing an easy upgrade path for the code.ConfigFragment Class
This class provides the basis of the framework for the shared methods.
CommonConfigFragment Class
This is an example of an implementation of ConfigFragment that is used in the
SinkCommonsConfig
SinkCommonConfig
This is a modified version of the code from #312. Not all code is present in this example, it is for discussion illumination only. The
SourceCommonsConfig
would be very similar.S3SinkConfig
This is not based on existing code but is an example of a clean implementation of the additional functionality mix-in. It assumes the existence of
S3AuthenticationFragment
which has not been presented here. And assumes that the S3SinkConnector will utilise the fluent access methods.Advantages of Config Fragments
Rejected Alternatives
ConfigDef
builder, but configuration issues at the KafkaSinkConnectorConfig
andSourceConnectorConfig
interface layers make this difficult to implement, and make the code more complex.Beta Was this translation helpful? Give feedback.
All reactions