Documentation ¶
Overview ¶
*
客户端
Index ¶
- func Close(client *grpc.ClientConn)
- func HealthCheck(grpcServer *grpc.Server)
- func NewClient(addr string) (*grpc.ClientConn, error)
- func Reflection(grpcServer *grpc.Server)
- func UnaryServerInterceptor(authFunc AuthFunc) grpc.UnaryServerInterceptor
- type AuthFunc
- type Config
- type HealthImpl
- type ServiceAuthOverride
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close(client *grpc.ClientConn)
func HealthCheck ¶
func Reflection ¶
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(authFunc AuthFunc) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptors that performs per-request auth.
Types ¶
type HealthImpl ¶
type HealthImpl struct{}
HealthImpl 健康检查实现
func (*HealthImpl) Check ¶
func (h *HealthImpl) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check 实现健康检查接口,这里直接返回健康状态,这里也可以有更复杂的健康检查策略,比如根据服务器负载来返回
func (*HealthImpl) Watch ¶
func (h *HealthImpl) Watch(req *grpc_health_v1.HealthCheckRequest, s grpc_health_v1.Health_WatchServer) error
Performs a watch for the serving status of the requested service. The server will immediately send back a message indicating the current serving status. It will then subsequently send a new message whenever the service's serving status changes.
If the requested service is unknown when the call is received, the server will send a message setting the serving status to SERVICE_UNKNOWN but will *not* terminate the call. If at some future point, the serving status of the service becomes known, the server will send a new message with the service's serving status.
If the call terminates with status UNIMPLEMENTED, then clients should assume this method is not supported and should not retry the call. If the call terminates with any other status (including OK), clients should retry the call with appropriate exponential backoff.
type ServiceAuthOverride ¶
type ServiceAuthOverride interface {
AuthFuncOverride(ctx context.Context, req interface{}, fullMethodName string) (context.Context, error)
}
ServiceAuthFuncOverride allows a given gRPC service implementation to override the global `AuthFunc`.
If a service implements the AuthFuncOverride method, it takes precedence over the `AuthFunc` method, and will be called instead of AuthFunc for all method invocations within that service.