kwpoll

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoLoader is the error returned when no Loader is set and Diff is set to true
	ErrNoLoader = errors.New("You must give a non nil Loader to the poll diff watcher")
	// ErrAlreadyClosed is the error returned when trying to close an already closed PollDiffWatcher
	ErrAlreadyClosed = errors.New("PollDiffWatcher already closed")
	// ErrNoWatcherSupplied is the error returned when Watch in general config is false but a watcher is still being registered
	ErrNoWatcherSupplied = errors.New("watcher has to be supplied when registering a watcher")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Rater is the rater the PollWatcher calls to get the duration until the next tick
	Rater Rater
	// Debug sets the debug mode
	Debug bool
	// Logger is the logger used to log debug messages
	Logger nlogger.Logger
	// Diff tells wether we should check for diffs
	// If diff is set, a Getter is required
	Diff bool
	// Loader is a loader to fetch data to check diff
	Loader konfig.Loader
	// InitValue is the initial value to compare with whe Diff is true
	InitValue konfig.Values
}

Config is the config of a PollWatcher

type PollWatcher

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

PollWatcher is a konfig.Watcher that sends events every x time given in the konfig.

func New

func New(cfg *Config) *PollWatcher

New creates a new PollWatcher fromt the given config

func (*PollWatcher) Close

func (t *PollWatcher) Close() error

Close closes the PollWatcher

func (*PollWatcher) Done

func (t *PollWatcher) Done() <-chan struct{}

Done indicates wether the watcher is done or not

func (*PollWatcher) Err

func (t *PollWatcher) Err() error

Err returns the poll watcher error

func (*PollWatcher) Start

func (t *PollWatcher) Start() error

Start starts the ticker watcher

func (*PollWatcher) Watch

func (t *PollWatcher) Watch() <-chan struct{}

Watch returns the channel to which events are written

type Rater

type Rater interface {
	Time() time.Duration
}

Rater is an interface that exposes a single Time method which returns the time until the next tick

type Time

type Time time.Duration

Time is a time.Duration which implements the Rater interface

func (Time) Time

func (t Time) Time() time.Duration

Time returns the time.Duration

Jump to

Keyboard shortcuts

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