Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrainStream ¶
func DrainStream[T any]( ctx context.Context, producer Producer[T], consumer Consumer[T], finisher ...Finisher, ) error
DrainStream invokes handler for every entity T read from repository stream.
Set a stream mode in context to change the handling of canceled context.
func WithStreamMode ¶
func WithStreamMode(ctx context.Context, mode StreamMode) context.Context
WithStreamMode specifies the stream mode to use for draining.
The default is Exhaustible.
Types ¶
type Producer ¶
Producer sends items on the stream channel.
The function is intended to be run as go routine. It must take care to close the channel, which signals the function is done. Closing is best deferred.
type StreamMode ¶
type StreamMode int
const ( // Exhaustible streams are eventually closed during program execution. // // Canceling the context is considered an error. Exhaustible StreamMode = iota + 1 // Infinite streams produce values indefinitely. // // Canceling the context is not considered an error. Infinite )
Click to show internal directories.
Click to hide internal directories.