Documentation ¶
Index ¶
- func Register(h Handler)
- type Client
- func (cli *Client) Close() error
- func (cli *Client) SendJSON(traceID uint64, seqID uint64, path string, data []byte, timeout uint) (rTraceID uint64, rSeqID uint64, rData []byte)
- func (cli *Client) SendSocket(node string, socketID uint32, ipAddr string, traceID uint64, seqID uint64, ...) (code uint32, rTraceID uint64, rSeqID uint64, rCmd uint32, rData []byte)
- type Handler
- type HealthImpl
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client struct
func CreateConnection ¶
CreateConnection with gRPC
type Handler ¶
type Handler interface { HandleCmd(node string, socketID uint32, ipAddr string, cmd uint32, data []byte) (code uint32, reply []byte) HandleJSON(path string, data []byte) (relpy []byte) }
Handler creates a service handler that will be used to handle message.
type HealthImpl ¶
type HealthImpl struct{}
HealthImpl grpc 健康检查 https://studygolang.com/articles/18737
func (*HealthImpl) Check ¶
func (h *HealthImpl) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check 实现健康检查接口,这里直接返回健康状态,这里也可以有更复杂的健康检查策略,比如根据服务器负载来返回 https://github.com/hashicorp/consul/blob/master/agent/checks/grpc.go consul 检查服务器的健康状态,consul 用 google.golang.org/grpc/health/grpc_health_v1.HealthServer 接口,实现了对 grpc健康检查的支持,所以我们只需要实现先这个接口,consul 就能利用这个接口作健康检查了
func (*HealthImpl) Watch ¶
func (h *HealthImpl) Watch(req *grpc_health_v1.HealthCheckRequest, w grpc_health_v1.Health_WatchServer) error
Watch HealthServer interface 有两个方法 Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) Watch(*HealthCheckRequest, Health_WatchServer) error 所以在 HealthImpl 结构提不仅要实现 Check 方法,还要实现 Watch 方法
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service detail
func CreateService ¶
CreateService serive