Use Set[string] instead of map[string]interface{} ServerType (#22853)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/22863/head
congqixia 2023-03-20 16:21:57 +08:00 committed by GitHub
parent 1f718118e9
commit 0317e0458b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 19 deletions

View File

@ -34,7 +34,7 @@ func (c *stop) execute(args []string, flags *flag.FlagSet) {
fmt.Fprintln(os.Stderr, c.getHelp())
}
c.serverType = args[2]
if _, ok := typeutil.ServerTypeMap()[c.serverType]; !ok {
if !typeutil.ServerTypeSet().Contain(c.serverType) {
fmt.Fprintf(os.Stderr, "Unknown server type = %s\n", c.serverType)
os.Exit(-1)
}

View File

@ -48,27 +48,26 @@ const (
IndexNodeRole = "indexnode"
)
var (
serverTypeSet = NewSet(
StandaloneRole,
RootCoordRole,
ProxyRole,
QueryCoordRole,
QueryNodeRole,
IndexNodeRole,
DataCoordRole,
DataNodeRole,
)
serverTypeList = serverTypeSet.Collect()
)
const Unlimited int64 = -1
func ServerTypeMap() map[string]interface{} {
return map[string]interface{}{
EmbeddedRole: nil,
StandaloneRole: nil,
RootCoordRole: nil,
ProxyRole: nil,
QueryCoordRole: nil,
QueryNodeRole: nil,
IndexNodeRole: nil,
DataCoordRole: nil,
DataNodeRole: nil,
}
func ServerTypeSet() Set[string] {
return serverTypeSet
}
func ServerTypeList() []string {
serverTypeMap := ServerTypeMap()
types := make([]string, 0, len(serverTypeMap))
for key := range serverTypeMap {
types = append(types, key)
}
return types
return serverTypeList
}