mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add stream assign server side implementation
This commit is contained in:
parent
ccedad5196
commit
94b7e2a37c
|
@ -3,6 +3,7 @@ package weed_server
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/seaweedfs/raft"
|
"github.com/seaweedfs/raft"
|
||||||
|
@ -15,6 +16,24 @@ import (
|
||||||
"github.com/seaweedfs/seaweedfs/weed/topology"
|
"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) {
|
func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest) (*master_pb.AssignResponse, error) {
|
||||||
|
|
||||||
if !ms.Topo.IsLeader() {
|
if !ms.Topo.IsLeader() {
|
||||||
|
|
Loading…
Reference in a new issue