Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringToWaitDurationHookFunc ¶ added in v0.11.1
func StringToWaitDurationHookFunc() mapstructure.DecodeHookFunc
StringToWaitDurationHookFunc returns a function that converts strings to wait value. This is designed to be used with mapstructure for parsing out a wait value.
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 dep.Dependency // Data is the most-recently-received data from Consul for this View Data interface{} ReceivedData bool LastIndex uint64 // 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(config *WatcherConfig, d dep.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 time.Duration `json:"min" mapstructure:"min"` Max time.Duration `json:"max" mapstructure:"max"` }
Wait is the Min/Max duration used by the Watcher
type WaitVar ¶ added in v0.7.0
type WaitVar Wait
WaitVar implements the Flag.Value interface and allows the user to specify a watch interval using Go's flag parsing library.
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 }
Watcher is a top-level manager for views that poll Consul for data.
func NewWatcher ¶
func NewWatcher(config *WatcherConfig) (*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) ForceWatching ¶ added in v0.12.0
func (w *Watcher) ForceWatching(d dep.Dependency, enabled bool)
ForceWatching is used to force setting the internal state of watching a depedency. This is only used for unit testing purposes.
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.
type WatcherConfig ¶ added in v0.6.5
type WatcherConfig struct { // Client is the mechanism for communicating with the Consul API. Clients *dep.ClientSet // Once is used to determine if the views should poll for data exactly once. Once bool // MaxStale is the maximum staleness of a query. If specified, Consul will // distribute work among all servers instead of just the leader. Specifying // this option assumes the use of AllowStale. MaxStale time.Duration // RetryFunc is a RetryFunc that represents the way retrys and backoffs // should occur. RetryFunc RetryFunc // RenewVault determines if the watcher should renew the Vault token as a // background job. RenewVault bool }
WatcherConfig is the configuration for a particular Watcher.