grpcutil

package
v2.0.0-beta.13 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 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     = "x-lava-client-name"
	ClientIpKey       = "x-lava-client-ip"
	ClientHostnameKey = "x-lava-client-hostname"
	ClientPathKey     = "x-lava-client-path"
	ClientVersionKey  = "x-lava-client-version"
)

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(md metadata.MD) string

ClientIP 获取对端ip

func ClientName

func ClientName(md metadata.MD) string

ClientName 获取对端应用名称

func ContextWithStats

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

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

func EnableAdmin

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

func HeaderGet(h Header, name string) string

func IsGRPCRequest

func IsGRPCRequest(r *http.Request) bool

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

func ListGRPCResources

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

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

WithClientApp 获取对端应用名称

func WithClientIp

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

Types

type GRPCStats

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

func StatsFromContext

func StatsFromContext(ctx context.Context) *GRPCStats

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

type GRPCStatsHandler

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

func NewGRPCStatsHandler() *GRPCStatsHandler

func (*GRPCStatsHandler) Close

func (c *GRPCStatsHandler) Close()

func (*GRPCStatsHandler) Collect

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

func (*GRPCStatsHandler) Describe

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

func (*GRPCStatsHandler) HandleConn

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

func (*GRPCStatsHandler) HandleRPC

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

func (*GRPCStatsHandler) TagConn

func (*GRPCStatsHandler) TagRPC

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