Browse Source

add stream assign server side implementation

pull/4787/head
chrislu 1 year ago
parent
commit
94b7e2a37c
  1. 19
      weed/server/master_grpc_server_assign.go

19
weed/server/master_grpc_server_assign.go

@ -3,6 +3,7 @@ package weed_server
import (
"context"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/glog"
"time"
"github.com/seaweedfs/raft"
@ -15,6 +16,24 @@ import (
"github.com/seaweedfs/seaweedfs/weed/topology"
)
func (ms *MasterServer) StreamAssign(server master_pb.Seaweed_StreamAssignServer) error {
for {
req, err := server.Recv()
if err != nil {
glog.Errorf("StreamAssign failed to receive: %v", err)
return err
}
resp, err := ms.Assign(context.Background(), req)
if err != nil {
glog.Errorf("StreamAssign failed to assign: %v", err)
return err
}
if err = server.Send(resp); err != nil {
glog.Errorf("StreamAssign failed to send: %v", err)
return err
}
}
}
func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest) (*master_pb.AssignResponse, error) {
if !ms.Topo.IsLeader() {

Loading…
Cancel
Save