streamutil

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: ISC Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errors

func Errors(errs ...stream.ErrorCloser) <-chan error

Errors takes a list of stream consumers and/or producers, and returns a combined errors channel on which any errors reported by the processors are delivered.

func ErrorsChan

func ErrorsChan(ch chan error, disabled bool) chan error

ErrorsChan returns the passed in errors channel, unless `disabled` is set to `true`, in which case a temporary new errors channel is created, and an error is returned, indicating that the errors channel cannot be used with the current streamconfig.

func HandleErrors

func HandleErrors(ch chan error, logger func(msg string, fields ...zapcore.Field))

HandleErrors listens to the provided channel, and triggers a fatal error when any error is received.

func HandleInterrupts

func HandleInterrupts(signals chan os.Signal, closer func() error, logger *zap.Logger)

HandleInterrupts monitors for an interrupt signal, and calls the provided closer function once received. It has a built-in timeout capability to force terminate the application when the closer takes too long to close, or returns an error during closing.

func Interrupt

func Interrupt() <-chan os.Signal

Interrupt returns a channel that receives a signal when the application receives either an SIGINT or SIGTERM signal. This is provided for convenience when dealing with a select statement and receiving stream messages, making it easy to cleanly exit after fully handling one message, but before handling the next message.

func Usage

func Usage(out io.Writer, about About) bool

Usage listens for `--help` and prints the relevant details on how to use the processor. A boolean is returned indicating if the usage documentation is printed, at which point the processor should probably exit.

Types

type About

type About struct {
	Name,
	URI,
	Usage string

	Consumers,
	Producers []string

	Config map[string]string
}

About provides details about the processor and its configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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