watch

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2015 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RetryFunc

type RetryFunc func(time.Duration) time.Duration

RetryFunc is a function that defines the retry for a given watcher. The function parameter is the current retry (which might be nil), and the return value is the new retry. In this way, you can build complex retry functions that are based off the previous values.

type View

type View struct {
	// Dependency is the dependency that is associated with this View
	Dependency dependency.Dependency

	// Data is the most-recently-received data from Consul for this View
	Data interface{}
	// contains filtered or unexported fields
}

View is a representation of a Dependency and the most recent data it has received from Consul.

func NewView

func NewView(client *api.Client, dep dependency.Dependency) (*View, error)

NewView creates a new view object from the given Consul API client and Dependency. If an error occurs, it will be returned.

type Wait

type Wait struct {
	// Min and Max are the minimum and maximum time, respectively, to wait for
	// data changes before rendering a new template to disk.
	Min, Max time.Duration
}

Wait is the Min/Max duration used by the Watcher

func ParseWait

func ParseWait(s string) (*Wait, error)

ParseWait parses a string of the format `minimum(:maximum)` into a Wait struct.

type Watcher

type Watcher struct {
	sync.Mutex

	// DataCh is the chan where Views will be published
	DataCh chan *View

	// ErrCh is the chan where any errors will be published
	ErrCh chan error

	// FinishCh is the chan where the watcher reports it is "done"
	FinishCh chan struct{}
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(c *api.Client, once bool) (*Watcher, error)

NewWatcher creates a new watcher using the given API client.

func (*Watcher) Add added in v0.6.0

func (w *Watcher) Add(d dep.Dependency) (bool, error)

Add adds the given dependency to the list of monitored depedencies and start the associated view. If the dependency already exists, no action is taken.

If the Dependency already existed, it this function will return false. If the view was successfully created, it will return true. If an error occurs while creating the view, it will be returned here (but future errors returned by the view will happen on the channel).

func (*Watcher) Remove added in v0.6.0

func (w *Watcher) Remove(d dep.Dependency) bool

Remove removes the given dependency from the list and stops the associated View. If a View for the given dependency does not exist, this function will return false. If the View does exist, this function will return true upon successful deletion.

func (*Watcher) SetRetry

func (w *Watcher) SetRetry(duration time.Duration)

SetRetry is used to set the retry to a static value. See SetRetryFunc for more informatoin.

func (*Watcher) SetRetryFunc

func (w *Watcher) SetRetryFunc(f RetryFunc)

SetRetryFunc is used to set a dynamic retry function. Only new views created after this function has been set will inherit the new retry functionality. Existing views will use the retry functionality with which they were created.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop halts this watcher and any currently polling views immediately. If a view was in the middle of a poll, no data will be returned.

func (*Watcher) Watching added in v0.6.0

func (w *Watcher) Watching(d dep.Dependency) bool

Watching determines if the given dependency is being watched.

Jump to

Keyboard shortcuts

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