Documentation ¶
Index ¶
- type RetryFunc
- type View
- type Wait
- type Watcher
- func (w *Watcher) Add(d dep.Dependency) (bool, error)
- func (w *Watcher) BatchSize() int
- func (w *Watcher) Remove(d dep.Dependency) bool
- func (w *Watcher) SetBatchSize(size int) error
- func (w *Watcher) SetRetry(duration time.Duration)
- func (w *Watcher) SetRetryFunc(f RetryFunc)
- func (w *Watcher) Stop()
- func (w *Watcher) Watching(d dep.Dependency) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RetryFunc ¶
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
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 ¶
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) BatchSize ¶ added in v0.6.1
BatchSize returns the current batch size for this watcher.
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) SetBatchSize ¶ added in v0.6.1
SetBatchSize sets the buffer for the DataCh for this watcher. By default, the batch size is 24, but larger systems may wish to increase this value.
This function will return an error if the watcher is currently running. The batch size can only be changed when there are exactly 0 views for this watcher.
func (*Watcher) SetRetry ¶
SetRetry is used to set the retry to a static value. See SetRetryFunc for more informatoin.
func (*Watcher) SetRetryFunc ¶
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.