grpcutil

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckServerVersion added in v0.4.3

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

CheckServerVersion implements a gRPC unary interceptor that requests the server version from SpiceDB and, if found, compares it to the current released version.

func ConcurrentBatch added in v0.4.4

func ConcurrentBatch(ctx context.Context, n int, batchSize int, maxWorkers int, each EachFunc) error

ConcurrentBatch will calculate the minimum number of batches to required to batch n items with batchSize batches. For each batch, it will execute the each function. These functions will be processed in parallel using maxWorkers number of goroutines. If maxWorkers is 1, then batching will happen sychronously. If maxWorkers is 0, then GOMAXPROCS number of workers will be used.

If an error occurs during a batch, all the worker's contexts are cancelled and the original error is returned.

func LogDispatchTrailers

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

LogDispatchTrailers implements a gRPC unary interceptor that logs the dispatch metadata that is present in response trailers from SpiceDB.

Types

type EachFunc added in v0.4.4

type EachFunc func(ctx context.Context, no int, start int, end int) error

EachFunc is a callback function that is called for each batch. no is the batch number, start is the starting index of this batch in the slice, and end is the ending index of this batch in the slice.

Jump to

Keyboard shortcuts

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