Documentation ¶
Index ¶
- func Close(client *grpc.ClientConn)
- func ErrIsDeadlineExceeded(err error) bool
- func HealthCheck(grpcServer *grpc.Server)
- func IsClosed(s *status.Status) bool
- func IsDeadlineExceeded(s *status.Status) bool
- func IsNeedAlarm(s *status.Status) bool
- func IsUnimplemented(s *status.Status) bool
- func NewClient(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func Reflection(grpcServer *grpc.Server)
- func UnaryServerInterceptor(authFunc AuthFunc) grpc.UnaryServerInterceptor
- func WithStatus(err error) *status.Status
- type AuthFunc
- type Client
- func (cli *Client) Alarm(method string, latency time.Duration, err error)
- func (cli *Client) CheckHealth() (int, error)
- func (cli *Client) Close()
- func (cli *Client) CreateConnect(opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func (cli *Client) HandlerError(conn *grpc.ClientConn, err error, start time.Time, method string) error
- func (cli *Client) WatchHealth() (grpc_health_v1.Health_WatchClient, error)
- type Config
- type HealthClient
- type HealthServer
- type OptionFunc
- type ServiceAuthOverride
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close(client *grpc.ClientConn)
func ErrIsDeadlineExceeded ¶ added in v1.20.71
func HealthCheck ¶
func IsDeadlineExceeded ¶ added in v1.8.8
func IsNeedAlarm ¶ added in v1.10.11
func IsUnimplemented ¶ added in v1.10.11
func NewClient ¶
func NewClient(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
func Reflection ¶
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(authFunc AuthFunc) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptors that performs per-request auth.
func WithStatus ¶ added in v1.1.12
Types ¶
type Client ¶ added in v1.1.9
type Client struct { Config // contains filtered or unexported fields }
func (*Client) CheckHealth ¶ added in v1.1.10
func (*Client) CreateConnect ¶ added in v1.1.9
func (cli *Client) CreateConnect(opts ...grpc.DialOption) (*grpc.ClientConn, error)
func (*Client) HandlerError ¶ added in v1.1.9
func (cli *Client) HandlerError(conn *grpc.ClientConn, err error, start time.Time, method string) error
HandlerError "State":"IDLE","Status":"rpc error: code = Unknown desc = rpc error: code = DeadlineExceeded desc = context deadline exceeded"}
func (*Client) WatchHealth ¶ added in v1.1.10
func (cli *Client) WatchHealth() (grpc_health_v1.Health_WatchClient, error)
type HealthClient ¶ added in v1.1.9
type HealthClient struct { }
func (*HealthClient) Check ¶ added in v1.1.9
func (client *HealthClient) Check(conn *grpc.ClientConn, service string, duration time.Duration) (int, error)
func (*HealthClient) Watch ¶ added in v1.1.9
func (client *HealthClient) Watch(conn *grpc.ClientConn, service string, duration time.Duration) (grpc_health_v1.Health_WatchClient, error)
type HealthServer ¶ added in v1.1.9
type HealthServer struct{}
HealthServer 健康检查实现
func (*HealthServer) Check ¶ added in v1.1.9
func (h *HealthServer) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check 实现健康检查接口,这里直接返回健康状态,这里也可以有更复杂的健康检查策略,比如根据服务器负载来返回
func (*HealthServer) Watch ¶ added in v1.1.9
func (h *HealthServer) Watch(req *grpc_health_v1.HealthCheckRequest, s grpc_health_v1.Health_WatchServer) error
Watch 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 OptionFunc ¶ added in v1.1.9
type OptionFunc func(conf *Config)
type ServiceAuthOverride ¶
type ServiceAuthOverride interface {
AuthFuncOverride(ctx context.Context, req interface{}, fullMethodName string) (context.Context, error)
}
ServiceAuthOverride 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.