rpc

package
v1.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2022 License: Zlib Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(client *grpc.ClientConn)

func HealthCheck

func HealthCheck(grpcServer *grpc.Server)

func NewClient

func NewClient(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func Reflection

func Reflection(grpcServer *grpc.Server)

func UnaryServerInterceptor

func UnaryServerInterceptor(authFunc AuthFunc) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptors that performs per-request auth.

Types

type AuthFunc

type AuthFunc func(ctx context.Context, req interface{}, fullMethodName string) (context.Context, error)

type Client added in v1.1.9

type Client struct {
	Config
	// contains filtered or unexported fields
}

func (*Client) Alarm added in v1.1.9

func (cli *Client) Alarm(method string, latency time.Duration, err error)

func (*Client) CheckHealth added in v1.1.10

func (cli *Client) CheckHealth() (int, error)

func (*Client) Close added in v1.1.9

func (cli *Client) Close()

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

func (*Client) WatchHealth added in v1.1.10

func (cli *Client) WatchHealth() (grpc_health_v1.Health_WatchClient, error)

type Config

type Config struct {
	Timeout time.Duration
	Server  string
	Service string
	Title   string
}

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

Check 实现健康检查接口,这里直接返回健康状态,这里也可以有更复杂的健康检查策略,比如根据服务器负载来返回

func (*HealthServer) Watch added in v1.1.9

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.

type Status added in v1.1.12

type Status struct {
	*status.Status
}

func WithStatus added in v1.1.12

func WithStatus(err error) *Status

func (*Status) IsClosed added in v1.1.12

func (s *Status) IsClosed() bool

func (*Status) IsDeadlineExceeded added in v1.1.12

func (s *Status) IsDeadlineExceeded() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL