|
- package rpc
-
- import (
- "context"
-
- "gitlink.org.cn/cloudream/jcs-pub/common/ecode"
- "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
- clirpc "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc/client"
- )
-
- func (svc *Service) GetClusterMasterInfo(ctx context.Context, msg *clirpc.GetClusterMasterInfo) (*clirpc.GetClusterMasterInfoResp, *rpc.CodeError) {
- return &clirpc.GetClusterMasterInfoResp{Name: svc.cluster.Name()}, nil
- }
-
- func (s *Service) ClusterRaftRPC(ctx context.Context, msg *clirpc.ClusterRaftRPC) (*clirpc.ClusterRaftRPCResp, *rpc.CodeError) {
- return s.cluster.RaftTransport().OnRPC(msg)
- }
-
- func (s *Service) ClusterRaftInstallSnapshot(ctx context.Context, msg *clirpc.ClusterRaftInstallSnapshot) (*clirpc.ClusterRaftInstallSnapshotResp, *rpc.CodeError) {
- return s.cluster.RaftTransport().OnInstallSnapshot(msg)
- }
-
- func (s *Service) ClusterApplyLog(ctx context.Context, msg *clirpc.ClusterApplyLog) (*clirpc.ClusterApplyLogResp, *rpc.CodeError) {
- ret, err := s.cluster.Apply(msg.FSMID, msg.Data, msg.Timeout)
- if err != nil {
- return nil, rpc.Failed(ecode.OperationFailed, "%v", err)
- }
-
- return &clirpc.ClusterApplyLogResp{
- Result: ret,
- }, nil
- }
|