mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +08:00
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package service
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"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/streaming/proto/streamingpb"
|
|
"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,
|
|
listenerTotal: metrics.StreamingCoordAssignmentListenerTotal.WithLabelValues(paramtable.GetStringNodeID()),
|
|
}
|
|
}
|
|
|
|
type AssignmentService interface {
|
|
streamingpb.StreamingCoordAssignmentServiceServer
|
|
}
|
|
|
|
// assignmentServiceImpl is the implementation of the assignment service.
|
|
type assignmentServiceImpl struct {
|
|
balancer balancer.Balancer
|
|
listenerTotal prometheus.Gauge
|
|
}
|
|
|
|
// AssignmentDiscover watches the state of all log nodes.
|
|
func (s *assignmentServiceImpl) AssignmentDiscover(server streamingpb.StreamingCoordAssignmentService_AssignmentDiscoverServer) error {
|
|
s.listenerTotal.Inc()
|
|
defer s.listenerTotal.Dec()
|
|
|
|
return discover.NewAssignmentDiscoverServer(s.balancer, server).Execute()
|
|
}
|