xgrpc

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: GPL-3.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context, addr string, credentials credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error)

NewClient creates new gRPC client connection on given addr and wraps it with given credentials (if provided).

The address argument can be optionally used as other peer's verification using ETH authentication. To enable this the argument should be in format "ethAddr@Endpoint".

func NewQUICClient added in v0.4.17

func NewQUICClient(ctx context.Context, addr string, tlsConfig *tls.Config, credentials credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func NewServer

func NewServer(logger *zap.Logger, extraOpts ...ServerOption) *grpc.Server

func OpenTracingZapUnaryInterceptor added in v0.4.13

func OpenTracingZapUnaryInterceptor() grpc.UnaryServerInterceptor

func RequestLogUnaryInterceptor added in v0.4.13

func RequestLogUnaryInterceptor(truncatedMethods map[string]bool) grpc.UnaryServerInterceptor

func Services added in v0.4.5

func Services(server *grpc.Server) []string

func VerifyUnaryInterceptor added in v0.4.13

func VerifyUnaryInterceptor() grpc.UnaryServerInterceptor

func WithConn added in v0.4.1

func WithConn(conn net.Conn) grpc.DialOption

WithConn is a client option that specifies a predefined connection used for a service.

Types

type Handler

type Handler struct{}

func (*Handler) HandleConn

func (h *Handler) HandleConn(ctx context.Context, connStats stats.ConnStats)

HandleConn processes the Conn stats.

func (*Handler) HandleRPC

func (h *Handler) HandleRPC(context.Context, stats.RPCStats)

HandleRPC processes the RPC stats.

func (*Handler) TagConn

func (h *Handler) TagConn(ctx context.Context, connTagInfo *stats.ConnTagInfo) context.Context

func (*Handler) TagRPC

func (h *Handler) TagRPC(ctx context.Context, rpcTagInfo *stats.RPCTagInfo) context.Context

type MethodInfo added in v0.4.6

type MethodInfo struct {
	Service string
	Method  string
}

func ParseMethodInfo added in v0.4.13

func ParseMethodInfo(fullMethod string) *MethodInfo

func (*MethodInfo) IntoTuple added in v0.4.13

func (m *MethodInfo) IntoTuple() (string, string)

type ServerOption

type ServerOption func(options *options)

func AuthorizationInterceptor

func AuthorizationInterceptor(router *auth.AuthRouter) ServerOption

func Credentials

Credentials activates credentials for server connections.

func DefaultTraceInterceptor

func DefaultTraceInterceptor() ServerOption

func GRPCServerOptions added in v0.4.17

func GRPCServerOptions(opts ...grpc.ServerOption) ServerOption

func RateLimitInterceptor added in v0.4.12

func RateLimitInterceptor(ctx context.Context, defaultLimit float64, preciseLimits map[string]float64) ServerOption

RateLimitInterceptor is an option that enables requests rate limit for specified methods.

The context is required, because internally a garbage collector is run to periodically collect records for addresses that are inactive for a long time.

Rates are counted as exponentially-weighted averaged at one-minutes.

Methods that are not listed in the "preciseLimits" argument will have no rate limitations.

func RequestLogInterceptor added in v0.4.6

func RequestLogInterceptor(truncatedMethods []string) ServerOption

RequestLogInterceptor is an options that activates gRPC service call logging before the real execution begins.

Note, that to enable tracing logging you should specify this option AFTER trace interceptors.

func StreamServerInterceptor added in v0.4.13

func StreamServerInterceptor(s grpc.StreamServerInterceptor) ServerOption

UnaryServerInterceptor adds an unary interceptor to the chain.

func TraceInterceptor

func TraceInterceptor(tracer opentracing.Tracer) ServerOption

func UnaryServerInterceptor

func UnaryServerInterceptor(u grpc.UnaryServerInterceptor) ServerOption

UnaryServerInterceptor adds an unary interceptor to the chain.

func VerifyInterceptor added in v0.4.1

func VerifyInterceptor() ServerOption

VerifyInterceptor is an interceptor that performs server-side validation for both gRPC request and reply if possible.

It automatically checks whether those types has `Validate` method and calls it if so.

type TransportCredentials added in v0.4.17

type TransportCredentials struct {
	credentials.TransportCredentials
	TLSConfig *tls.Config
}

TransportCredentials wraps the standard transport credentials, adding an ability to obtain the TLS config used.

func NewTransportCredentials added in v0.4.17

func NewTransportCredentials(cfg *tls.Config) *TransportCredentials

Jump to

Keyboard shortcuts

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