Files
akvorado/orchestrator/kafka/config.go
rastsislau-matusevich f2dfe55d27
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled
Update Nix dependency hashes / Update dependency hashes (push) Has been cancelled
orchestrator: add manage-topic flag and document skip-migrations (#2109)
2025-11-20 22:58:41 +01:00

56 lines
1.8 KiB
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package kafka
import (
"akvorado/common/kafka"
)
// Configuration describes the configuration for the Kafka configurator.
type Configuration struct {
kafka.Configuration `mapstructure:",squash" yaml:",inline"`
// ManageTopic tells if the Kafka topic should be managed (create/update). Default is true.
ManageTopic bool
// TopicConfiguration describes the topic configuration.
TopicConfiguration TopicConfiguration
}
// TopicConfiguration describes the configuration for a topic
type TopicConfiguration struct {
// NumPartitions tells how many partitions should be used for the topic.
NumPartitions int32 `validate:"min=1"`
// ReplicationFactor tells the replication factor for the topic.
ReplicationFactor int16 `validate:"min=1"`
// ConfigEntries is a map to specify the topic overrides. Non-listed overrides will be removed by default.
ConfigEntries map[string]*string
// ConfigEntriesStrictSync says if non-listed overrides should be removed (strict sync) or not. Default is True.
ConfigEntriesStrictSync bool
}
// DefaultConfiguration represents the default configuration for the Kafka configurator.
func DefaultConfiguration() Configuration {
return Configuration{
Configuration: kafka.DefaultConfiguration(),
ManageTopic: true,
TopicConfiguration: TopicConfiguration{
NumPartitions: 1,
ReplicationFactor: 1,
ConfigEntriesStrictSync: true,
},
}
}
// ShouldAlterConfiguration validates if topic configuration update is needed regarding in-sync policy.
func ShouldAlterConfiguration(target, source map[string]*string, strict bool) bool {
for k, v := range target {
if ov, ok := source[k]; !ok || *ov != *v {
return true
}
}
if !strict {
return false
}
return len(target) != len(source)
}