-
Notifications
You must be signed in to change notification settings - Fork 31
Optional kafka segment configs #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
83f65f2
d7d6fd2
b5d58a0
7dfac48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -282,7 +282,7 @@ func (sc *StreamConsumerImpl) start() { | |
| metrics.ConnectionMessageStatuses(sc.destination.Id(), sc.tableName, "deadLettered").Inc() | ||
| failedTopic = sc.config.KafkaDestinationsDeadLetterTopicName | ||
| } else { | ||
| err = sc.topicManager.ensureTopic(sc.retryTopic, 1, sc.topicManager.RetryTopicConfig()) | ||
| err = sc.topicManager.ensureTopic(sc.retryTopic, 1, sc.topicManager.config.TopicConfig("retry")) | ||
|
||
| if err != nil { | ||
| sc.Errorf("failed to create retry topic %s: %v", sc.retryTopic, err) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ type KafkaConfig struct { | |
| KafkaTopicCompression string `mapstructure:"KAFKA_TOPIC_COMPRESSION" default:"snappy"` | ||
| KafkaTopicRetentionHours int `mapstructure:"KAFKA_TOPIC_RETENTION_HOURS" default:"48"` | ||
| KafkaTopicSegmentHours int `mapstructure:"KAFKA_TOPIC_SEGMENT_HOURS" default:"24"` | ||
| KafkaAllowSegmentConfig bool `mapstructure:"KAFKA_ALLOW_SEGMENT_CONFIG" default:"true"` | ||
| KafkaTopicPrefix string `mapstructure:"KAFKA_TOPIC_PREFIX" default:""` | ||
| KafkaFetchMessageMaxBytes int `mapstructure:"KAFKA_FETCH_MESSAGE_MAX_BYTES" default:"1048576"` | ||
|
|
||
|
|
@@ -91,6 +92,34 @@ func (ac *KafkaConfig) GetKafkaConfig() *kafka.ConfigMap { | |
| return kafkaConfig | ||
| } | ||
|
|
||
| func (c *KafkaConfig) TopicConfig(mode string) map[string]string { | ||
| config := map[string]string{} | ||
|
|
||
| switch mode { | ||
| case "retry": | ||
| config["retention.ms"] = fmt.Sprint(c.KafkaTopicRetentionHours * 60 * 60 * 1000) | ||
|
||
| config["cleanup.policy"] = "delete,compact" | ||
|
|
||
| if c.KafkaAllowSegmentConfig { | ||
| config["segment.bytes"] = fmt.Sprint(c.KafkaRetryTopicSegmentBytes) | ||
| config["segment.ms"] = fmt.Sprint(c.KafkaTopicSegmentHours * 60 * 60 * 1000) | ||
| } | ||
| case "dead": | ||
| config["retention.ms"] = fmt.Sprint(c.KafkaDeadTopicRetentionHours * 60 * 60 * 1000) | ||
| config["cleanup.policy"] = "delete,compact" | ||
| if c.KafkaAllowSegmentConfig { | ||
| config["segment.ms"] = fmt.Sprint(c.KafkaTopicSegmentHours * 60 * 60 * 1000) | ||
| } | ||
| default: | ||
| config["compression.type"] = c.KafkaTopicCompression | ||
|
||
| config["retention.ms"] = fmt.Sprint(c.KafkaTopicRetentionHours * 60 * 60 * 1000) | ||
| if c.KafkaAllowSegmentConfig { | ||
| config["segment.ms"] = fmt.Sprint(c.KafkaTopicSegmentHours * 60 * 60 * 1000) | ||
| } | ||
| } | ||
| return config | ||
| } | ||
|
|
||
| func (c *KafkaConfig) PostInit(settings *appbase.AppSettings) error { | ||
| return nil | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bchasconfigproperty too