mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +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>
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"github.com/milvus-io/milvus/internal/proto/streamingpb"
|
|
"github.com/milvus-io/milvus/internal/streamingcoord/server/balancer"
|
|
"github.com/milvus-io/milvus/internal/streamingcoord/server/service/discover"
|
|
"github.com/milvus-io/milvus/pkg/metrics"
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
|
)
|
|
|
|
var _ streamingpb.StreamingCoordAssignmentServiceServer = (*assignmentServiceImpl)(nil)
|
|
|
|
// NewAssignmentService returns a new assignment service.
|
|
func NewAssignmentService(
|
|
balancer balancer.Balancer,
|
|
) streamingpb.StreamingCoordAssignmentServiceServer {
|
|
return &assignmentServiceImpl{
|
|
balancer: balancer,
|
|
}
|
|
}
|
|
|
|
type AssignmentService interface {
|
|
streamingpb.StreamingCoordAssignmentServiceServer
|
|
}
|
|
|
|
// assignmentServiceImpl is the implementation of the assignment service.
|
|
type assignmentServiceImpl struct {
|
|
balancer balancer.Balancer
|
|
}
|
|
|
|
// AssignmentDiscover watches the state of all log nodes.
|
|
func (s *assignmentServiceImpl) AssignmentDiscover(server streamingpb.StreamingCoordAssignmentService_AssignmentDiscoverServer) error {
|
|
metrics.StreamingCoordAssignmentListenerTotal.WithLabelValues(paramtable.GetStringNodeID()).Inc()
|
|
defer metrics.StreamingCoordAssignmentListenerTotal.WithLabelValues(paramtable.GetStringNodeID()).Dec()
|
|
|
|
return discover.NewAssignmentDiscoverServer(s.balancer, server).Execute()
|
|
}
|