[ 
https://issues.apache.org/jira/browse/KAFKA-4436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15703620#comment-15703620
 ] 

Matthias J. Sax commented on KAFKA-4436:
----------------------------------------

bq. One of the goals in making KafkaStreams part of Apache Kafka was to make 
sure there are consistent APIs and tools that make things easier to users who 
are used to "normal clients" to adopt more advanced features.

Completely agreed.

That is why I like the idea to change it for other configs like 
Producer/Consumer, too. If more people think, that is the right way to go, we 
can just extend the scope of this JIRA. One main difference with regard to 
Streams might be the people who are using it. Streams targets an even broader 
application developer audience and thus ease to use might even be more 
important. Furthermore, in Streams, there are a few configuration that are 
fixed and cannot be changed by the user (for example setting auto commit). 
Using builder pattern would help to avoid that users change it (there might be 
more such settings in the future) -- a feature like this is of course not 
required for consumer/producer clients where all setting are valid.

> Provide builder pattern for StreamsConfig
> -----------------------------------------
>
>                 Key: KAFKA-4436
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4436
>             Project: Kafka
>          Issue Type: Improvement
>          Components: streams
>            Reporter: Matthias J. Sax
>            Priority: Minor
>
> Currently, {{StreamsConfig}} parameters must be set "manually" as key value 
> pairs. This has multiple disadvantages from a user point of view:
>  - mandatory arguments could be missing
>  - data types might be wrong
>  - producer/consumer config parameters could conflict as they might have the 
> same name (user needs to know to prefix them to avoid conflict)
> Those problems have different impact: either a runtime exception is thrown if 
> the problem is detected (e.g. missing parameter or wrong type) or the 
> application is just not configured correctly (producer/consumer has wrong 
> config).
> A builder pattern would avoid those problems by forcing the user in the first 
> place to specify thing correctly (otherwise, it won't compile). For example 
> something like this:
> {noformat}
> StreamsConfig config = StreamsConfig.builder()
>     .setApplicationId(String appId)
>     .addBootstrapServer(String host, int port)
>     .addBootstrapServer(String host, int port)
>     .addZookeeper(String host, int port)
>     .addZookeeper(String host, int port)
>     .setStateDirectory(File path)
>     .setConsumerConfig(
>         ConsumerConfig.builder()
>             .setAutoOffsetReset(...)
>             .build()
>     )
>     .build();
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to