watcher

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	Persister    types.Persister // Persister to load and store state with.
	Reader       types.Reader    // Reader to read logs from.
	Logger       log.Logger      // Logger to use.
	InitialState types.State
}

Params contains parameters for NewWatcher.

type Watcher

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

Watcher is a component that wraps a Reader and takes care of loading and storing state before an after calling Reader.ReadLogs. It ensures that each Reader never reads the same messages that were previously read.

func New

func New(params Params) *Watcher

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context, ch chan<- types.Message) (err error)

Watch loads the state and invokes the Reader.ReadLogs. It persists the state after the reading is done. The ch will be closed after reading is complete.

func (*Watcher) WatchAsync

func (w *Watcher) WatchAsync(ctx context.Context, ch chan<- types.Message) <-chan error

WatchAsync calls Watch in a separate goroutine and returns a channel that will return an error upon completion. The resulting channel is buffered so it does not need to be read from.

Jump to

Keyboard shortcuts

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