resumer

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewResumer = func(config Config) (*Resumer, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	rr := &Resumer{config: config}
	err := catacomb.Invoke(catacomb.Plan{
		Site: &rr.catacomb,
		Work: rr.loop,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return rr, nil
}

NewResumer returns a new Resumer or an error. If the Resumer is not nil, the caller is responsible for stopping it via `Kill()` and handling any error returned from `Wait()`.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency manifold that runs a resumer worker, using the resources named or defined in the supplied config.

func NewWorker

func NewWorker(config Config) (worker.Worker, error)

NewWorker returns a useful live implementation for ManifoldConfig.NewWorker.

Types

type Config

type Config struct {
	Facade   Facade
	Clock    clock.Clock
	Interval time.Duration
}

Config holds the dependencies and configuration necessary to drive a Resumer.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if config cannot be expected to drive a Resumer.

type Facade

type Facade interface {

	// ResumeTransactions resumes all pending transactions.
	ResumeTransactions() error
}

Facade defines the interface for types capable of resuming transactions.

func NewFacade

func NewFacade(apiCaller base.APICaller) (Facade, error)

NewFacade returns a useful live implementation for ManifoldConfig.NewFacade.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName     string
	APICallerName string
	Clock         clock.Clock
	Interval      time.Duration
	NewFacade     func(base.APICaller) (Facade, error)
	NewWorker     func(Config) (worker.Worker, error)
}

ManifoldConfig defines the names of the manifolds on which a Manifold will depend.

type Resumer

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

Resumer is responsible for periodically resuming all pending transactions.

func (*Resumer) Kill

func (rr *Resumer) Kill()

Kill is part of the worker.Worker interface.

func (*Resumer) Wait

func (rr *Resumer) Wait() error

Wait is part of the worker.Worker interface.

Jump to

Keyboard shortcuts

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