messagesize

package
v0.0.0-...-72f9500 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

This section is empty.

Functions

func MustGetClientMessageSizeFromEnv

func MustGetClientMessageSizeFromEnv() []grpc.DialOption

MustGetClientMessageSizeFromEnv returns a slice of grpc.DialOptions that set the maximum message size for gRPC clients if the "SRC_GRPC_CLIENT_MAX_MESSAGE_SIZE" environment variable is set to a valid size value (ex: "40 MB").

If the environment variable isn't set, it returns nil. If the size value in the environment variable is invalid (too small, not parsable, etc.), it panics.

func MustGetServerMessageSizeFromEnv

func MustGetServerMessageSizeFromEnv() []grpc.ServerOption

MustGetServerMessageSizeFromEnv returns a slice of grpc.ServerOption that set the maximum message size for gRPC servers if the "SRC_GRPC_SERVER_MAX_MESSAGE_SIZE" environment variable is set to a valid size value (ex: "40 MB").

If the environment variable isn't set, it returns nil. If the size value in the environment variable is invalid (too small, not parsable, etc.), it panics.

func StreamClientInterceptor

func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)

StreamClientInterceptor is a grpc.StreamClientInterceptor that records Prometheus metrics that observe both the sizes of the individual request messages and the cumulative request size of all the message sent by the client over the course of a single RPC call.

func StreamServerInterceptor

func StreamServerInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamServerInterceptor is a grpc.StreamServerInterceptor that records Prometheus metrics that observe both the sizes of the individual response messages and the cumulative response size of all the message sent back by the server over the course of a single RPC call.

func UnaryClientInterceptor

func UnaryClientInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

UnaryClientInterceptor is a grpc.UnaryClientInterceptor that records Prometheus metrics that observe the size of the request message sent by client for a single RPC call.

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)

UnaryServerInterceptor is a grpc.UnaryServerInterceptor that records Prometheus metrics that observe the size of the response message sent back by the server for a single RPC call.

Types

This section is empty.

Jump to

Keyboard shortcuts

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