grpcutils

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: GPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const CustomErrorMetadataKey = "Custom-Error"

CustomErrorMetadataKey is the name of the metadata key storing additional error information. Metadata value is expected to be a byte-encoded JSON object.

View Source
const HttpCodeMetadataKey = "X-Http-Code"

HttpCodeMetadataKey is the key to use when setting custom HTTP status codes in gRPC metadata.

Variables

This section is empty.

Functions

func AppendCustomErrorHeader added in v1.4.1

func AppendCustomErrorHeader(ctx context.Context, errorData interface{}) error

AppendCustomErrorHeader sets a CustomErrorMetadataKey gRPC header on the passed in context, using the passed in error data as the header's value. The data is serialized as JSON.

func AppendHeaders added in v1.2.0

func AppendHeaders(parent context.Context, headers []string) context.Context

AppendHeaders parses the provided GRPC headers and attaches them to the provided context.

func LogRequests added in v1.2.0

func LogRequests(
	ctx context.Context,
	method string, req,
	reply interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption,
) error

LogRequests logs the gRPC backend as well as request duration when the log level is set to debug or higher.

func LogStream added in v1.2.0

func LogStream(
	ctx context.Context,
	sd *grpc.StreamDesc,
	conn *grpc.ClientConn,
	method string,
	streamer grpc.Streamer,
	opts ...grpc.CallOption,
) (grpc.ClientStream, error)

LogStream prints the method at DEBUG level at the start of the stream.

Types

This section is empty.

Jump to

Keyboard shortcuts

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