grpcutil

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultContentType = "application/grpc"
	DefaultTimeout     = time.Second * 2
)
View Source
const (
	ClientNameKey     = "client-name"
	ClientIpKey       = "client-ip"
	ClientHostnameKey = "client-hostname"
	ClientPathKey     = "client-path"
	ClientVersionKey  = "client-version"
)

Variables

This section is empty.

Functions

func ClientIP added in v0.2.11

func ClientIP(md metadata.MD) string

ClientIP 获取对端ip

func ClientName added in v0.2.11

func ClientName(md metadata.MD) string

ClientName 获取对端应用名称

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 ListGRPCResources added in v0.2.11

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

ListGRPCResources is a helper function that lists all URLs that are registered on gRPC server.

This makes it easy to register all the relevant routes in your HTTP router of choice.

func WithClientApp added in v0.2.11

func WithClientApp(ctx context.Context, name string) context.Context

WithClientApp 获取对端应用名称

func WithClientIp added in v0.2.11

func WithClientIp(ctx context.Context, ip string) context.Context

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