mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-05 18:31:59 +08:00
issue: #33285 - add balancer implementation - add channel count fair balance policy - add channel assignment discover grpc service Signed-off-by: chyezh <chyezh@outlook.com>
31 lines
996 B
Go
31 lines
996 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
|
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
|
)
|
|
|
|
// GetAllTopicsFromConfiguration gets all topics from configuration.
|
|
// It's a utility function to fetch all topics from configuration.
|
|
func GetAllTopicsFromConfiguration() typeutil.Set[string] {
|
|
var channels typeutil.Set[string]
|
|
if paramtable.Get().CommonCfg.PreCreatedTopicEnabled.GetAsBool() {
|
|
channels = typeutil.NewSet[string](paramtable.Get().CommonCfg.TopicNames.GetAsStrings()...)
|
|
} else {
|
|
channels = genChannelNames(paramtable.Get().CommonCfg.RootCoordDml.GetValue(), paramtable.Get().RootCoordCfg.DmlChannelNum.GetAsInt())
|
|
}
|
|
return channels
|
|
}
|
|
|
|
// genChannelNames generates channel names with prefix and number.
|
|
func genChannelNames(prefix string, num int) typeutil.Set[string] {
|
|
results := typeutil.NewSet[string]()
|
|
for idx := 0; idx < num; idx++ {
|
|
result := fmt.Sprintf("%s_%d", prefix, idx)
|
|
results.Insert(result)
|
|
}
|
|
return results
|
|
}
|