|
- package clirpc
-
- import (
- "context"
- "io"
- "time"
-
- "github.com/hashicorp/raft"
- "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
- )
-
- type ClusterService interface {
- GetClusterMasterInfo(ctx context.Context, req *GetClusterMasterInfo) (*GetClusterMasterInfoResp, *rpc.CodeError)
- ClusterRaftRPC(ctx context.Context, req *ClusterRaftRPC) (*ClusterRaftRPCResp, *rpc.CodeError)
- ClusterRaftInstallSnapshot(ctx context.Context, req *ClusterRaftInstallSnapshot) (*ClusterRaftInstallSnapshotResp, *rpc.CodeError)
- ClusterApplyLog(ctx context.Context, req *ClusterApplyLog) (*ClusterApplyLogResp, *rpc.CodeError)
- }
-
- type GetClusterMasterInfo struct {
- }
-
- type GetClusterMasterInfoResp struct {
- Name string
- }
-
- func (c *Client) GetClusterMasterInfo(ctx context.Context, msg *GetClusterMasterInfo) (*GetClusterMasterInfoResp, *rpc.CodeError) {
- if c.fusedErr != nil {
- return nil, c.fusedErr
- }
-
- return rpc.UnaryClient[*GetClusterMasterInfoResp](c.cli.GetClusterMasterInfo, ctx, msg)
- }
- func (s *Server) GetClusterMasterInfo(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
- return rpc.UnaryServer(s.svrImpl.GetClusterMasterInfo, ctx, msg)
- }
-
- type ClusterRaftRPC struct {
- Type string
- Data string
- }
-
- type ClusterRaftRPCResp struct {
- Data string
- }
-
- func (c *Client) ClusterRaftRPC(ctx context.Context, msg *ClusterRaftRPC) (*ClusterRaftRPCResp, *rpc.CodeError) {
- if c.fusedErr != nil {
- return nil, c.fusedErr
- }
-
- return rpc.UnaryClient[*ClusterRaftRPCResp](c.cli.ClusterRaftRPC, ctx, msg)
- }
- func (s *Server) ClusterRaftRPC(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
- return rpc.UnaryServer(s.svrImpl.ClusterRaftRPC, ctx, msg)
- }
-
- type ClusterRaftInstallSnapshot struct {
- Args *raft.InstallSnapshotRequest
- Data io.Reader `json:"-"`
- }
-
- func (r *ClusterRaftInstallSnapshot) GetStream() io.Reader {
- return r.Data
- }
-
- func (r *ClusterRaftInstallSnapshot) SetStream(stream io.Reader) {
- r.Data = stream
- }
-
- type ClusterRaftInstallSnapshotResp struct {
- Resp *raft.InstallSnapshotResponse
- }
-
- func (c *Client) ClusterRaftInstallSnapshot(ctx context.Context, msg *ClusterRaftInstallSnapshot) (*ClusterRaftInstallSnapshotResp, *rpc.CodeError) {
- if c.fusedErr != nil {
- return nil, c.fusedErr
- }
-
- return rpc.UploadStreamClient[*ClusterRaftInstallSnapshotResp](c.cli.ClusterRaftInstallSnapshot, ctx, msg)
- }
-
- func (s *Server) ClusterRaftInstallSnapshot(req Client_ClusterRaftInstallSnapshotServer) error {
- return rpc.UploadStreamServer(s.svrImpl.ClusterRaftInstallSnapshot, req)
- }
-
- type ClusterApplyLog struct {
- Data string
- Timeout time.Duration
- }
- type ClusterApplyLogResp struct{}
-
- func (c *Client) ClusterApplyLog(ctx context.Context, msg *ClusterApplyLog) (*ClusterApplyLogResp, *rpc.CodeError) {
- if c.fusedErr != nil {
- return nil, c.fusedErr
- }
-
- return rpc.UnaryClient[*ClusterApplyLogResp](c.cli.ClusterApplyLog, ctx, msg)
- }
- func (s *Server) ClusterApplyLog(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
- return rpc.UnaryServer(s.svrImpl.ClusterApplyLog, ctx, msg)
- }
|