goroflow

package
v0.0.0-...-e7774ac Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start[T any](ctx context.Context, logger Logger, processors ...Processor[T]) (<-chan T, <-chan error)

Start manages worker goroutines to process items in provided channels. If logger is nil, it defaults to NoOpLogger.

Types

type Logger

type Logger interface {
	Info(msg string, keysAndValues ...interface{})
	Error(msg string, keysAndValues ...interface{})
}

Logger interface that all loggers must implement

type NoOpLogger

type NoOpLogger struct{}

NoOpLogger default logger that does nothing

func (*NoOpLogger) Error

func (n *NoOpLogger) Error(msg string, keysAndValues ...interface{})

func (*NoOpLogger) Info

func (n *NoOpLogger) Info(msg string, keysAndValues ...interface{})

type Processor

type Processor[T any] struct {
	ProcessFunc func(T) (T, error)
	Chans       []<-chan T
}

Processor is a structure holding processing function and associated channels.

type ZapLoggerAdapter

type ZapLoggerAdapter struct {
	// contains filtered or unexported fields
}

ZapLoggerAdapter adapts a zap.Logger to our Logger interface.

func NewZapLoggerAdapter

func NewZapLoggerAdapter(z *zap.Logger) *ZapLoggerAdapter

func (*ZapLoggerAdapter) Error

func (z *ZapLoggerAdapter) Error(msg string, keysAndValues ...interface{})

func (*ZapLoggerAdapter) Info

func (z *ZapLoggerAdapter) Info(msg string, keysAndValues ...interface{})

Jump to

Keyboard shortcuts

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