Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-4436

Provide builder pattern for StreamsConfig

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • streams

    Description

      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:

      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();
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mjsax Matthias J. Sax
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated: