grpc

package
v0.0.0-...-25be6c5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromError

func FromError(err error) error

FromError will de-serialise the details from the status into an Error

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 intercepts errors, de-serialising any WrappedErrors we find and unpacking any context jettison key-values.

func StreamServerInterceptor

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

StreamServerInterceptor intercepts errors, de-serialising any WrappedErrors we find and unpacking any context jettison key-values.

func UnaryClientInterceptor

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

UnaryClientInterceptor intercepts errors, de-serialising any // WrappedErrors we find and unpacking any context jettison key-values.

func UnaryServerInterceptor

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

UnaryServerInterceptor intercepts errors, de-serialising any WrappedErrors we find and unpacking any context jettison key-values.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error wraps an error and a status. For outgoing errors, it allows us to create the grpc status and store it until needed. For incoming errors, we can store the original status from grpc, so we can check it later for certain codes this allows us to communicate context errors across grpc.

func Wrap

func Wrap(err error) Error

Wrap will construct an Error that will serialise err when needed by gRPC by exposing the GRPCStatus method

func (Error) Error

func (g Error) Error() string

func (Error) GRPCStatus

func (g Error) GRPCStatus() *status.Status

func (Error) Is

func (g Error) Is(target error) bool

func (Error) Unwrap

func (g Error) Unwrap() error

Directories

Path Synopsis
internal
test

Jump to

Keyboard shortcuts

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