| @@ -189,13 +189,10 @@ func (c *Core) acquire(cmd Acquire) { | |||
| // 立刻检测锁是否可用 | |||
| cerr := c.tryAcquireOne(cmd.ID, cmd.Request) | |||
| if cerr == nil { | |||
| err := c.eventCh.Send(&AcquireResult{ | |||
| c.eventCh.Send(&AcquireResult{ | |||
| Raw: cmd, | |||
| Error: nil, | |||
| }) | |||
| if err != nil { | |||
| panic(err) | |||
| } | |||
| return | |||
| } | |||
| @@ -216,7 +213,7 @@ func (c *Core) acquire(cmd Acquire) { | |||
| data, err := serder.ObjectToJSONEx(ac) | |||
| if err != nil { | |||
| log.Warnf("cmd %T to json: %v", cmd, err) | |||
| log.Warnf("cmd %T to json: %v", ac, err) | |||
| return | |||
| } | |||
| @@ -270,7 +267,7 @@ func (c *Core) leaseExpired(cmd LeaseExpired) { | |||
| return | |||
| } | |||
| log.Warnf("lock request %v lease expired", ac.ID) | |||
| log.Debugf("lock request %v lease expired", ac.ID) | |||
| c.releaseRequest(ac.ID, ac.Req) | |||
| c.tryAcquirings() | |||
| @@ -1,31 +0,0 @@ | |||
| package types | |||
| type AcquireMsg struct { | |||
| ContextID string | |||
| Request LockRequest | |||
| Option AcquireOption | |||
| } | |||
| func (*AcquireMsg) IsPubLockMessage() bool { return true } | |||
| type AcquireResultMsg struct { | |||
| ContextID string | |||
| Success bool | |||
| Error string | |||
| RequestID RequestID | |||
| } | |||
| func (*AcquireResultMsg) IsPubLockMessage() bool { return true } | |||
| type ReleaseMsg struct { | |||
| ContextID string | |||
| RequestID RequestID | |||
| } | |||
| func (*ReleaseMsg) IsPubLockMessage() bool { return true } | |||
| type ReleaseResultMsg struct { | |||
| ContextID string | |||
| } | |||
| func (*ReleaseResultMsg) IsPubLockMessage() bool { return true } | |||
| @@ -1,54 +0,0 @@ | |||
| package rpc | |||
| import ( | |||
| "gitlink.org.cn/cloudream/common/pkgs/logger" | |||
| "gitlink.org.cn/cloudream/jcs-pub/client/internal/publock/types" | |||
| clirpc "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc/client" | |||
| ) | |||
| func (s *Service) PubLockChannel(ch clirpc.PubLockMessageChan) { | |||
| log := logger.WithField("Mod", "RPC") | |||
| for { | |||
| msg, cerr := ch.Receive() | |||
| if cerr != nil { | |||
| log.Warnf("receive publock message: %v", cerr.ToError()) | |||
| break | |||
| } | |||
| switch msg := msg.(type) { | |||
| case *types.AcquireMsg: | |||
| go func() { | |||
| lkd, err := s.pubLock.Acquire(msg.Request, msg.Option) | |||
| if err != nil { | |||
| cerr := ch.Send(&types.AcquireResultMsg{ | |||
| ContextID: msg.ContextID, | |||
| Success: false, | |||
| Error: err.Error(), | |||
| }) | |||
| if cerr != nil { | |||
| log.Warnf("send acquire result message: %v", cerr.ToError()) | |||
| } | |||
| return | |||
| } | |||
| cerr := ch.Send(&types.AcquireResultMsg{ | |||
| ContextID: msg.ContextID, | |||
| Success: true, | |||
| RequestID: lkd.ReqID, | |||
| }) | |||
| if cerr != nil { | |||
| log.Warnf("send acquire result message: %v", cerr.ToError()) | |||
| } | |||
| }() | |||
| case *types.ReleaseMsg: | |||
| s.pubLock.Release(msg.RequestID) | |||
| cerr := ch.Send(&types.ReleaseResultMsg{ | |||
| ContextID: msg.ContextID, | |||
| }) | |||
| if cerr != nil { | |||
| log.Warnf("send release result message: %v", cerr.ToError()) | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -234,33 +234,30 @@ var file_pkgs_rpc_client_client_proto_rawDesc = []byte{ | |||
| 0x28, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, | |||
| 0x10, 0x2e, 0x63, 0x6c, 0x69, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x4b, | |||
| 0x56, 0x52, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x42, 0x6f, 0x64, | |||
| 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x32, 0xd2, 0x02, | |||
| 0x0a, 0x06, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x31, 0x0a, 0x0e, 0x50, 0x75, 0x62, 0x4c, | |||
| 0x6f, 0x63, 0x6b, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x0c, 0x2e, 0x72, 0x70, 0x63, | |||
| 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, | |||
| 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x33, 0x0a, 0x14, 0x47, | |||
| 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x49, | |||
| 0x6e, 0x66, 0x6f, 0x12, 0x0c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, | |||
| 0x74, 0x1a, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, | |||
| 0x12, 0x2d, 0x0a, 0x0e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x61, 0x66, 0x74, 0x52, | |||
| 0x50, 0x43, 0x12, 0x0c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, | |||
| 0x1a, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, | |||
| 0x3f, 0x0a, 0x1a, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x61, 0x66, 0x74, 0x49, 0x6e, | |||
| 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x12, 0x10, 0x2e, | |||
| 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x1a, | |||
| 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, | |||
| 0x12, 0x2e, 0x0a, 0x0f, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x41, 0x70, 0x70, 0x6c, 0x79, | |||
| 0x4c, 0x6f, 0x67, 0x12, 0x0c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, | |||
| 0x74, 0x1a, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, | |||
| 0x12, 0x40, 0x0a, 0x09, 0x48, 0x54, 0x54, 0x50, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x18, 0x2e, | |||
| 0x63, 0x6c, 0x69, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x50, 0x72, 0x6f, 0x78, 0x79, | |||
| 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x63, 0x6c, 0x69, 0x72, 0x70, 0x63, | |||
| 0x2e, 0x48, 0x54, 0x54, 0x50, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, | |||
| 0x73, 0x65, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x6f, 0x72, | |||
| 0x67, 0x2e, 0x63, 0x6e, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x6a, | |||
| 0x63, 0x73, 0x2d, 0x70, 0x75, 0x62, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x6b, | |||
| 0x67, 0x73, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6c, 0x69, 0x72, 0x70, 0x63, 0x3b, 0x63, 0x6c, | |||
| 0x69, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |||
| 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x32, 0x9f, 0x02, | |||
| 0x0a, 0x06, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x33, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, | |||
| 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, | |||
| 0x12, 0x0c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, | |||
| 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, | |||
| 0x0e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x61, 0x66, 0x74, 0x52, 0x50, 0x43, 0x12, | |||
| 0x0c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, | |||
| 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x1a, | |||
| 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x61, 0x66, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, | |||
| 0x6c, 0x6c, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, | |||
| 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x1a, 0x0d, 0x2e, 0x72, | |||
| 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x12, 0x2e, 0x0a, | |||
| 0x0f, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x6f, 0x67, | |||
| 0x12, 0x0c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, | |||
| 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, | |||
| 0x09, 0x48, 0x54, 0x54, 0x50, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x18, 0x2e, 0x63, 0x6c, 0x69, | |||
| 0x72, 0x70, 0x63, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, | |||
| 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x63, 0x6c, 0x69, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x54, | |||
| 0x54, 0x50, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, | |||
| 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x63, | |||
| 0x6e, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x6a, 0x63, 0x73, 0x2d, | |||
| 0x70, 0x75, 0x62, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x6b, 0x67, 0x73, 0x2f, | |||
| 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6c, 0x69, 0x72, 0x70, 0x63, 0x3b, 0x63, 0x6c, 0x69, 0x72, 0x70, | |||
| 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |||
| } | |||
| var ( | |||
| @@ -287,20 +284,18 @@ var file_pkgs_rpc_client_client_proto_goTypes = []any{ | |||
| var file_pkgs_rpc_client_client_proto_depIdxs = []int32{ | |||
| 0, // 0: clirpc.HTTPProxyRequest.Header:type_name -> clirpc.HeaderKV | |||
| 0, // 1: clirpc.HTTPProxyResponse.Header:type_name -> clirpc.HeaderKV | |||
| 3, // 2: clirpc.Client.PubLockChannel:input_type -> rpc.Request | |||
| 3, // 3: clirpc.Client.GetClusterMasterInfo:input_type -> rpc.Request | |||
| 3, // 4: clirpc.Client.ClusterRaftRPC:input_type -> rpc.Request | |||
| 4, // 5: clirpc.Client.ClusterRaftInstallSnapshot:input_type -> rpc.ChunkedData | |||
| 3, // 6: clirpc.Client.ClusterApplyLog:input_type -> rpc.Request | |||
| 1, // 7: clirpc.Client.HTTPProxy:input_type -> clirpc.HTTPProxyRequest | |||
| 5, // 8: clirpc.Client.PubLockChannel:output_type -> rpc.Response | |||
| 5, // 9: clirpc.Client.GetClusterMasterInfo:output_type -> rpc.Response | |||
| 5, // 10: clirpc.Client.ClusterRaftRPC:output_type -> rpc.Response | |||
| 5, // 11: clirpc.Client.ClusterRaftInstallSnapshot:output_type -> rpc.Response | |||
| 5, // 12: clirpc.Client.ClusterApplyLog:output_type -> rpc.Response | |||
| 2, // 13: clirpc.Client.HTTPProxy:output_type -> clirpc.HTTPProxyResponse | |||
| 8, // [8:14] is the sub-list for method output_type | |||
| 2, // [2:8] is the sub-list for method input_type | |||
| 3, // 2: clirpc.Client.GetClusterMasterInfo:input_type -> rpc.Request | |||
| 3, // 3: clirpc.Client.ClusterRaftRPC:input_type -> rpc.Request | |||
| 4, // 4: clirpc.Client.ClusterRaftInstallSnapshot:input_type -> rpc.ChunkedData | |||
| 3, // 5: clirpc.Client.ClusterApplyLog:input_type -> rpc.Request | |||
| 1, // 6: clirpc.Client.HTTPProxy:input_type -> clirpc.HTTPProxyRequest | |||
| 5, // 7: clirpc.Client.GetClusterMasterInfo:output_type -> rpc.Response | |||
| 5, // 8: clirpc.Client.ClusterRaftRPC:output_type -> rpc.Response | |||
| 5, // 9: clirpc.Client.ClusterRaftInstallSnapshot:output_type -> rpc.Response | |||
| 5, // 10: clirpc.Client.ClusterApplyLog:output_type -> rpc.Response | |||
| 2, // 11: clirpc.Client.HTTPProxy:output_type -> clirpc.HTTPProxyResponse | |||
| 7, // [7:12] is the sub-list for method output_type | |||
| 2, // [2:7] is the sub-list for method input_type | |||
| 2, // [2:2] is the sub-list for extension type_name | |||
| 2, // [2:2] is the sub-list for extension extendee | |||
| 0, // [0:2] is the sub-list for field type_name | |||
| @@ -26,8 +26,6 @@ message HTTPProxyResponse { | |||
| service Client { | |||
| rpc PubLockChannel(stream rpc.Request) returns(stream rpc.Response); | |||
| rpc GetClusterMasterInfo(rpc.Request) returns(rpc.Response); | |||
| rpc ClusterRaftRPC(rpc.Request) returns(rpc.Response); | |||
| rpc ClusterRaftInstallSnapshot(stream rpc.ChunkedData) returns(rpc.Response); | |||
| @@ -20,7 +20,6 @@ import ( | |||
| const _ = grpc.SupportPackageIsVersion7 | |||
| const ( | |||
| Client_PubLockChannel_FullMethodName = "/clirpc.Client/PubLockChannel" | |||
| Client_GetClusterMasterInfo_FullMethodName = "/clirpc.Client/GetClusterMasterInfo" | |||
| Client_ClusterRaftRPC_FullMethodName = "/clirpc.Client/ClusterRaftRPC" | |||
| Client_ClusterRaftInstallSnapshot_FullMethodName = "/clirpc.Client/ClusterRaftInstallSnapshot" | |||
| @@ -32,7 +31,6 @@ const ( | |||
| // | |||
| // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. | |||
| type ClientClient interface { | |||
| PubLockChannel(ctx context.Context, opts ...grpc.CallOption) (Client_PubLockChannelClient, error) | |||
| GetClusterMasterInfo(ctx context.Context, in *rpc.Request, opts ...grpc.CallOption) (*rpc.Response, error) | |||
| ClusterRaftRPC(ctx context.Context, in *rpc.Request, opts ...grpc.CallOption) (*rpc.Response, error) | |||
| ClusterRaftInstallSnapshot(ctx context.Context, opts ...grpc.CallOption) (Client_ClusterRaftInstallSnapshotClient, error) | |||
| @@ -48,37 +46,6 @@ func NewClientClient(cc grpc.ClientConnInterface) ClientClient { | |||
| return &clientClient{cc} | |||
| } | |||
| func (c *clientClient) PubLockChannel(ctx context.Context, opts ...grpc.CallOption) (Client_PubLockChannelClient, error) { | |||
| stream, err := c.cc.NewStream(ctx, &Client_ServiceDesc.Streams[0], Client_PubLockChannel_FullMethodName, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| x := &clientPubLockChannelClient{stream} | |||
| return x, nil | |||
| } | |||
| type Client_PubLockChannelClient interface { | |||
| Send(*rpc.Request) error | |||
| Recv() (*rpc.Response, error) | |||
| grpc.ClientStream | |||
| } | |||
| type clientPubLockChannelClient struct { | |||
| grpc.ClientStream | |||
| } | |||
| func (x *clientPubLockChannelClient) Send(m *rpc.Request) error { | |||
| return x.ClientStream.SendMsg(m) | |||
| } | |||
| func (x *clientPubLockChannelClient) Recv() (*rpc.Response, error) { | |||
| m := new(rpc.Response) | |||
| if err := x.ClientStream.RecvMsg(m); err != nil { | |||
| return nil, err | |||
| } | |||
| return m, nil | |||
| } | |||
| func (c *clientClient) GetClusterMasterInfo(ctx context.Context, in *rpc.Request, opts ...grpc.CallOption) (*rpc.Response, error) { | |||
| out := new(rpc.Response) | |||
| err := c.cc.Invoke(ctx, Client_GetClusterMasterInfo_FullMethodName, in, out, opts...) | |||
| @@ -98,7 +65,7 @@ func (c *clientClient) ClusterRaftRPC(ctx context.Context, in *rpc.Request, opts | |||
| } | |||
| func (c *clientClient) ClusterRaftInstallSnapshot(ctx context.Context, opts ...grpc.CallOption) (Client_ClusterRaftInstallSnapshotClient, error) { | |||
| stream, err := c.cc.NewStream(ctx, &Client_ServiceDesc.Streams[1], Client_ClusterRaftInstallSnapshot_FullMethodName, opts...) | |||
| stream, err := c.cc.NewStream(ctx, &Client_ServiceDesc.Streams[0], Client_ClusterRaftInstallSnapshot_FullMethodName, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -153,7 +120,6 @@ func (c *clientClient) HTTPProxy(ctx context.Context, in *HTTPProxyRequest, opts | |||
| // All implementations must embed UnimplementedClientServer | |||
| // for forward compatibility | |||
| type ClientServer interface { | |||
| PubLockChannel(Client_PubLockChannelServer) error | |||
| GetClusterMasterInfo(context.Context, *rpc.Request) (*rpc.Response, error) | |||
| ClusterRaftRPC(context.Context, *rpc.Request) (*rpc.Response, error) | |||
| ClusterRaftInstallSnapshot(Client_ClusterRaftInstallSnapshotServer) error | |||
| @@ -166,9 +132,6 @@ type ClientServer interface { | |||
| type UnimplementedClientServer struct { | |||
| } | |||
| func (UnimplementedClientServer) PubLockChannel(Client_PubLockChannelServer) error { | |||
| return status.Errorf(codes.Unimplemented, "method PubLockChannel not implemented") | |||
| } | |||
| func (UnimplementedClientServer) GetClusterMasterInfo(context.Context, *rpc.Request) (*rpc.Response, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method GetClusterMasterInfo not implemented") | |||
| } | |||
| @@ -197,32 +160,6 @@ func RegisterClientServer(s grpc.ServiceRegistrar, srv ClientServer) { | |||
| s.RegisterService(&Client_ServiceDesc, srv) | |||
| } | |||
| func _Client_PubLockChannel_Handler(srv interface{}, stream grpc.ServerStream) error { | |||
| return srv.(ClientServer).PubLockChannel(&clientPubLockChannelServer{stream}) | |||
| } | |||
| type Client_PubLockChannelServer interface { | |||
| Send(*rpc.Response) error | |||
| Recv() (*rpc.Request, error) | |||
| grpc.ServerStream | |||
| } | |||
| type clientPubLockChannelServer struct { | |||
| grpc.ServerStream | |||
| } | |||
| func (x *clientPubLockChannelServer) Send(m *rpc.Response) error { | |||
| return x.ServerStream.SendMsg(m) | |||
| } | |||
| func (x *clientPubLockChannelServer) Recv() (*rpc.Request, error) { | |||
| m := new(rpc.Request) | |||
| if err := x.ServerStream.RecvMsg(m); err != nil { | |||
| return nil, err | |||
| } | |||
| return m, nil | |||
| } | |||
| func _Client_GetClusterMasterInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(rpc.Request) | |||
| if err := dec(in); err != nil { | |||
| @@ -346,12 +283,6 @@ var Client_ServiceDesc = grpc.ServiceDesc{ | |||
| }, | |||
| }, | |||
| Streams: []grpc.StreamDesc{ | |||
| { | |||
| StreamName: "PubLockChannel", | |||
| Handler: _Client_PubLockChannel_Handler, | |||
| ServerStreams: true, | |||
| ClientStreams: true, | |||
| }, | |||
| { | |||
| StreamName: "ClusterRaftInstallSnapshot", | |||
| Handler: _Client_ClusterRaftInstallSnapshot_Handler, | |||
| @@ -1,27 +0,0 @@ | |||
| package clirpc | |||
| import ( | |||
| "context" | |||
| "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc" | |||
| ) | |||
| type PubLockService interface { | |||
| PubLockChannel(tx PubLockMessageChan) | |||
| } | |||
| type PubLockMessage interface { | |||
| IsPubLockMessage() bool | |||
| } | |||
| type PubLockMessageChan = rpc.BidChan[PubLockMessage, PubLockMessage] | |||
| func (c *Client) PubLockChannel(ctx context.Context) PubLockMessageChan { | |||
| if c.fusedErr != nil { | |||
| return rpc.NewFusedChan[PubLockMessage, PubLockMessage](c.fusedErr) | |||
| } | |||
| return rpc.BidChannelClient[PubLockMessage, PubLockMessage](c.cli.PubLockChannel, ctx) | |||
| } | |||
| func (s *Server) PubLockChannel(arg Client_PubLockChannelServer) error { | |||
| return rpc.BidChannelServer(s.svrImpl.PubLockChannel, arg) | |||
| } | |||
| @@ -6,7 +6,6 @@ import ( | |||
| type ClientAPI interface { | |||
| ClusterService | |||
| PubLockService | |||
| HTTPService | |||
| } | |||