public class TopicConfigBuilder extends Object
TopicConfigBuilder.BuildSteps
is a functional pattern for setting topic configuration
Whenever a TopicConfigBuilder.BuildSteps
is required, a user can provide a lambda function of this form for example:
builder -> builder
.withDefaultTopicSpec(partitions, replication, retentionInDays)
.with
.withTopicPrefix("prefix")
*
This pattern allows the framework flexibility how it treats this configuration, without complicating the user interaction
as the framework determines when the config is built.
The topic configuration covers both the topic naming conventions, as well as the configuration required to create the missing topics.
This pattern enables topics names and configurations to have sensible out the box defaults, so minimal up-front configuration is required, but still allow for complete flexibility.
Modifier and Type | Class and Description |
---|---|
static interface |
TopicConfigBuilder.BuildSteps
A functional interface representing a configuration step that is applied to a topic builder
|
Modifier and Type | Method and Description |
---|---|
TopicConfigBuilder |
withDefaultTopicSpec(int partitions,
int replication,
int retentionInDays)
Sets the topic spec by default topic to be the topic spec with the specified partitions and replication factor, as well as the setting the topic retention
|
TopicConfigBuilder |
withNamingStrategy(io.simplesource.kafka.api.ResourceNamingStrategy namingStrategy)
Sets the the resource naming strategy for topic creation
|
TopicConfigBuilder |
withTopicBaseName(String topicBaseName)
Sets the base name for topic creation when applying the prefix resource naming strategy
|
TopicConfigBuilder |
withTopicNameOverride(String topicType,
String topicName)
Overrides the topic name for a given topic type
|
TopicConfigBuilder |
withTopicNamer(TopicNamer topicNamer)
Explicitly sets the topic namer
|
TopicConfigBuilder |
withTopicPrefix(String prefix)
Sets the resource naming strategy to
PrefixResourceNamingStrategy with the given prefix |
TopicConfigBuilder |
withTopicSpecOverride(String topicType,
io.simplesource.kafka.spec.TopicSpec topicSpec)
Overrides the topic spec for a given topic type
|
public TopicConfigBuilder withNamingStrategy(io.simplesource.kafka.api.ResourceNamingStrategy namingStrategy)
namingStrategy
- the naming strategypublic TopicConfigBuilder withTopicPrefix(String prefix)
PrefixResourceNamingStrategy
with the given prefixprefix
- the prefixpublic TopicConfigBuilder withTopicBaseName(String topicBaseName)
topicBaseName
- the topic base namepublic TopicConfigBuilder withTopicNamer(TopicNamer topicNamer)
topicNamer
- the topic namerpublic TopicConfigBuilder withTopicNameOverride(String topicType, String topicName)
topicType
- the topic typetopicName
- the topic namepublic TopicConfigBuilder withTopicSpecOverride(String topicType, io.simplesource.kafka.spec.TopicSpec topicSpec)
topicType
- the topic typetopicSpec
- the topic specpublic TopicConfigBuilder withDefaultTopicSpec(int partitions, int replication, int retentionInDays)
partitions
- the partitionsreplication
- the replicationretentionInDays
- the retention in daysCopyright © 2019. All rights reserved.