grpcutil

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

DefaultUnaryMiddleware is a recommended set of middleware that should each gracefully no-op if the middleware is not applicable.

Functions

func ContextWithStats added in v0.1.26

func ContextWithStats(ctx context.Context, stats *GRPCStats) context.Context

ContextWithStats Returns a new `context.Context` that holds a reference to `GRPCStats`.

func EnableAdmin added in v0.1.26

func EnableAdmin(s grpc.ServiceRegistrar) (cleanup func(), _ error)

func EnableDebug

func EnableDebug(s *grpc.Server)

func EnableHealth

func EnableHealth(srv string, s *grpc.Server)

func EnableReflection

func EnableReflection(s *grpc.Server)

func HeaderGet added in v0.2.1

func HeaderGet(h Header, name string) string

func IsGRPCRequest added in v0.1.26

func IsGRPCRequest(r *http.Request) bool

IsGRPCRequest returns true if the message is considered to be a GRPC message

func NewAuthlessReflectionInterceptor

func NewAuthlessReflectionInterceptor(srv reflection.GRPCServer) reflection.GRPCServer

NewAuthlessReflectionInterceptor creates a proxy GRPCServer which automatically converts ServerReflectionServer instances to onces that skip grpc auth middleware.

change: reflection.Register(srv) to: reflection.Register(grpcutil.NewAuthlessReflectionInterceptor(srv))

func NoopUnaryInterceptor

func NoopUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

NoopUnaryInterceptor is a gRPC middleware that does not do anything.

func WithCustomCerts

func WithCustomCerts(certPath string, insecureSkipVerify bool) grpc.DialOption

WithCustomCerts is a dial option for requiring TLS from a specified path. If the path is a directory, all certs are loaded. If it is an individual file only the directly specified cert is loaded.

This function panics if custom certificate pool cannot be instantiated.

func WithSystemCerts

func WithSystemCerts(insecureSkipVerify bool) grpc.DialOption

WithSystemCerts is a dial option for requiring TLS with the system certificate pool.

This function panics if the system pool cannot be loaded.

func WrapMethods

func WrapMethods(svcDesc grpc.ServiceDesc, interceptors ...grpc.UnaryServerInterceptor) (wrapped *grpc.ServiceDesc)

WrapMethods wraps all non-streaming endpoints with the given list of interceptors. It returns a copy of the ServiceDesc with the new wrapped methods.

func WrapStreams

func WrapStreams(svcDesc grpc.ServiceDesc, interceptors ...grpc.StreamServerInterceptor) (wrapped *grpc.ServiceDesc)

WrapStreams wraps all streaming endpoints with the given list of interceptors. It returns a copy of the ServiceDesc with the new wrapped methods.

Types

type GRPCStats added in v0.1.26

type GRPCStats struct {
	Duration clock.Duration
	Method   string
	Failed   float64
	Success  float64
}

func StatsFromContext added in v0.1.26

func StatsFromContext(ctx context.Context) *GRPCStats

StatsFromContext Returns the `GRPCStats` previously associated with `ctx`.

type GRPCStatsHandler added in v0.1.26

type GRPCStatsHandler struct {
	// contains filtered or unexported fields
}

GRPCStatsHandler Implements the Prometheus collector interface. Such that when the /metrics handler is called this collector pulls all the stats from

func NewGRPCStatsHandler added in v0.1.26

func NewGRPCStatsHandler() *GRPCStatsHandler

func (*GRPCStatsHandler) Close added in v0.1.26

func (c *GRPCStatsHandler) Close()

func (*GRPCStatsHandler) Collect added in v0.1.26

func (c *GRPCStatsHandler) Collect(ch chan<- prometheus.Metric)

func (*GRPCStatsHandler) Describe added in v0.1.26

func (c *GRPCStatsHandler) Describe(ch chan<- *prometheus.Desc)

func (*GRPCStatsHandler) HandleConn added in v0.1.26

func (c *GRPCStatsHandler) HandleConn(ctx context.Context, s stats.ConnStats)

func (*GRPCStatsHandler) HandleRPC added in v0.1.26

func (c *GRPCStatsHandler) HandleRPC(ctx context.Context, s stats.RPCStats)

func (*GRPCStatsHandler) TagConn added in v0.1.26

func (*GRPCStatsHandler) TagRPC added in v0.1.26

func (c *GRPCStatsHandler) TagRPC(ctx context.Context, tagInfo *stats.RPCTagInfo) context.Context
type Header = metadata.MD

Jump to

Keyboard shortcuts

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