43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package hubrpc
|
|
|
|
import (
|
|
context "context"
|
|
|
|
rpc "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
|
|
)
|
|
|
|
type MicsSvc interface {
|
|
Ping(ctx context.Context, req *Ping) (*PingResp, *rpc.CodeError)
|
|
GetState(ctx context.Context, req *GetState) (*GetStateResp, *rpc.CodeError)
|
|
}
|
|
|
|
// 测试延迟
|
|
type Ping struct{}
|
|
type PingResp struct{}
|
|
|
|
var _ = TokenAuth(Hub_Ping_FullMethodName)
|
|
|
|
func (c *Client) Ping(ctx context.Context, req *Ping) (*PingResp, *rpc.CodeError) {
|
|
if c.fusedErr != nil {
|
|
return nil, c.fusedErr
|
|
}
|
|
return rpc.UnaryClient[*PingResp](c.cli.Ping, ctx, req)
|
|
}
|
|
func (s *Server) Ping(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
|
|
return rpc.UnaryServer(s.svrImpl.Ping, ctx, req)
|
|
}
|
|
|
|
// 获取状态
|
|
type GetState struct{}
|
|
type GetStateResp struct{}
|
|
|
|
func (c *Client) GetState(ctx context.Context, req *GetState) (*GetStateResp, *rpc.CodeError) {
|
|
if c.fusedErr != nil {
|
|
return nil, c.fusedErr
|
|
}
|
|
return rpc.UnaryClient[*GetStateResp](c.cli.GetState, ctx, req)
|
|
}
|
|
func (s *Server) GetState(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
|
|
return rpc.UnaryServer(s.svrImpl.GetState, ctx, req)
|
|
}
|