Zhen Ye c84a0748c4
enhance: add rw/ro streaming query node replica management (#38677)
issue: #38399

- Embed the query node into streaming node to make delegator available
at streaming node.
- The embedded query node has a special server label
`QUERYNODE_STREAMING-EMBEDDED`.
- Change the balance strategy to make the channel assigned to streaming
node as much as possible.

Signed-off-by: chyezh <chyezh@outlook.com>
2025-01-24 16:55:07 +08:00

34 lines
1.2 KiB
Go

package streamingutil
import (
"os"
"github.com/milvus-io/milvus/internal/util/sessionutil"
)
const MilvusStreamingServiceEnabled = "MILVUS_STREAMING_SERVICE_ENABLED"
// IsStreamingServiceEnabled returns whether the streaming service is enabled.
func IsStreamingServiceEnabled() bool {
// TODO: check if the environment variable MILVUS_STREAMING_SERVICE_ENABLED is set
return os.Getenv(MilvusStreamingServiceEnabled) == "1"
}
// MustEnableStreamingService panics if the streaming service is not enabled.
func MustEnableStreamingService() {
if !IsStreamingServiceEnabled() {
panic("start a streaming node without enabling streaming service, please set environment variable MILVUS_STREAMING_SERVICE_ENABLED = 1")
}
}
// EnableEmbededQueryNode set server labels for embedded query node.
func EnableEmbededQueryNode() {
MustEnableStreamingService()
os.Setenv(sessionutil.SupportedLabelPrefix+sessionutil.LabelStreamingNodeEmbeddedQueryNode, "1")
}
// IsEmbeddedQueryNode returns whether the current node is an embedded query node in streaming node.
func IsEmbeddedQueryNode() bool {
return os.Getenv(sessionutil.SupportedLabelPrefix+sessionutil.LabelStreamingNodeEmbeddedQueryNode) == "1"
}