util

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteAsync

func ExecuteAsync(n int, f func(i int) (interface{}, error)) ([]interface{}, error)

ExecuteAsync executes the given function f up to n times concurrently, populating the given results slice with the results of each function call. Each call is done in a separate goroutine. On each iteration, the function f will be called with a unique sequential index i such that the index can be used to reference an element in an array or slice. If an error is returned by the function f for any index, an error will be returned. Otherwise, a nil result will be returned once all function calls have completed.

func ExecuteOrderedAsync

func ExecuteOrderedAsync(n int, f func(i int) (interface{}, error)) ([]interface{}, error)

ExecuteOrderedAsync executes the given function f up to n times concurrently, populating the given results slice with the results of each function call. Each call is done in a separate goroutine. On each iteration, the function f will be called with a unique sequential index i such that the index can be used to reference an element in an array or slice. If an error is returned by the function f for any index, an error will be returned. Otherwise, a nil result will be returned once all function calls have completed.

func GetPartitionIndex

func GetPartitionIndex(key string, partitions int) (int, error)

GetPartitionIndex returns the index of the partition for the given key

func IterAsync

func IterAsync(n int, f func(i int) error) error

IterAsync executes the given function f up to n times concurrently. Each call is done in a separate goroutine. On each iteration, the function f will be called with a unique sequential index i such that the index can be used to reference an element in an array or slice. If an error is returned by the function f for any index, an error will be returned. Otherwise, a nil result will be returned once all function calls have completed.

func RetryingStreamClientInterceptor

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

RetryingStreamClientInterceptor returns a ClientStreamInterceptor that retries both requests and responses

func RetryingUnaryClientInterceptor

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

RetryingUnaryClientInterceptor returns a UnaryClientInterceptor that retries requests

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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