commons

package
v5.0.0-...-2679821 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEach

func ForEach[T any](streamClient StreamClient[T], openError error, handler ResponseHandler[T]) error

ForEach loops on the stream Recv() methods with proper error checking. The stream opening error is also checked first.

func MustStreamOne

func MustStreamOne[T any](streamClient StreamClient[T], openError error) (T, bool, error)

MustStreamOne is a shortcut to call for each and get first result.

Types

type ResponseHandler

type ResponseHandler[T any] func(T) error

type StreamClient

type StreamClient[T any] interface {
	grpc.ClientStream
	Recv() (T, error)
}

type StreamClientWrapper

type StreamClientWrapper[T any] interface {
	ForEach(handler ResponseHandler[T]) error
}

func WrapStream

func WrapStream[T any](sc StreamClient[T]) StreamClientWrapper[T]

WrapStream wraps a grpc stream client to add ForEach method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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