This repository was archived by the owner on Apr 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Optional kafka segment configs #29
Open
huoxito
wants to merge
4
commits into
jitsucom:main
Choose a base branch
from
huoxito:optional-kafka-segment-configs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
83f65f2
Support skipping segment kafka configs
huoxito d7d6fd2
use TopicConfig on batch and stream consumer
huoxito b5d58a0
set compression type for all modes
huoxito 7dfac48
Merge remote-tracking branch 'jitsu/main' into optional-kafka-segment…
huoxito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if err != nil { | ||
| sc.Errorf("failed to create retry topic %s: %v", sc.retryTopic, err) | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KafkaRetryTopicRetentionHours |
||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should set "compression.type" for all modes with map init |
||
| 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 | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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