grpc

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogRequest = grpc.UnaryServerInterceptor(func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
	log := ctrl.LoggerFrom(ctx)
	log.V(1).Info("Request")
	resp, err = handler(ctx, req)
	if err != nil {
		if code := status.Code(err); code == codes.Unknown {
			log.Error(err, "Unknown error handling request")
		}
	}
	return resp, err
})

LogRequest logs grpc requests. In case any request returns with status.Code == codes.Unknown, the error is logged.

Functions

func InjectLogger

func InjectLogger(log logr.Logger) grpc.UnaryServerInterceptor

InjectLogger injects the given logr.Logger into the context using ctrl.LoggerInto.

Types

This section is empty.

Jump to

Keyboard shortcuts

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