updater

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// Run has the Controller execute all the Updaters passed on the channel,
	// until it's closed. The method runs synchronously and only returns after
	// the channel is closed or the context is canceled.
	//
	// Any spawned goroutines should inherit the passed-in Context.
	//
	// A call to Run should be thought of as one execution of the Updaters.
	// If a caller wants to call Run in a loop, it should use a new channel on
	// each iteration.
	Run(context.Context, <-chan driver.Updater) error
}

Controller is the interface that updater Controllers implement.

type Offline added in v0.1.0

type Offline struct {
	// Output is used as the sink for calls to Run.
	//
	// A call to Run will write gzipped json objects to the Writer.
	// See the 'jsonblob' package for the details of the json format.
	//
	// This package does not take care of any framing for the writer.
	// If Run is called multiple times, this member should be reset accordingly.
	// That is, calling run multiple times with the same writer will result in
	// concatenated gzip blobs.
	Output io.Writer

	// If the Filter member is provided, the updater set's names will be passed
	// through it.
	Filter func(name string) (keep bool)
}

Offline is a controller for running Updaters in an offline matter.

func (*Offline) Run added in v0.1.0

func (o *Offline) Run(ctx context.Context, ch <-chan driver.Updater) error

Run implements Controller.

Run does no synchronization around the configured Writer. Returned results are always written, even if an error is ultimately returned from this function.

type Online added in v0.1.0

type Online struct {
	Pool    *pgxpool.Pool
	Workers int

	// If the Filter member is provided, the updater set's names will be passed
	// through it.
	Filter func(name string) (keep bool)
}

Online is a controller that writes updates to a database.

An Online should be constructed via a literal and is safe for concurrent use.

func (*Online) Run added in v0.1.0

func (e *Online) Run(ctx context.Context, ch <-chan driver.Updater) error

Run runs all the Updaters fed down the channel.

The method runs until the provided channel is closed or the context is cancelled.

Jump to

Keyboard shortcuts

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