Documentation ¶
Index ¶
- type NewViewInput
- type NewWatcherInput
- type RetryFunc
- type View
- type Watcher
- func (w *Watcher) Add(d dep.Dependency) (bool, error)
- func (w *Watcher) DataCh() <-chan *View
- func (w *Watcher) ErrCh() <-chan error
- func (w *Watcher) ForceWatching(d dep.Dependency, enabled bool)
- func (w *Watcher) Remove(d dep.Dependency) bool
- func (w *Watcher) Size() int
- 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 NewViewInput ¶ added in v0.18.0
type NewViewInput struct { // Dependency is the dependency to associate with the new view. Dependency dep.Dependency // Clients is the list of clients to communicate upstream. This is passed // directly to the dependency. Clients *dep.ClientSet // MaxStale is the maximum amount a time a query response is allowed to be // stale before forcing a read from the leader. MaxStale time.Duration // Once indicates this view should poll for data exactly one time. Once bool // RetryFunc is a function which dictates how this view should retry on // upstream errors. RetryFunc RetryFunc // VaultGrace is the grace period between a lease and the max TTL for which // Consul Template will generate a new secret instead of renewing an existing // one. VaultGrace time.Duration }
NewViewInput is used as input to the NewView function.
type NewWatcherInput ¶ added in v0.18.0
type NewWatcherInput struct { // Clients is the client set to communicate with upstreams. Clients *dep.ClientSet // MaxStale is the maximum staleness of a query. MaxStale time.Duration // Once specifies this watcher should tell views to poll exactly once. Once bool // RenewVault indicates if this watcher should renew Vault tokens. RenewVault bool // RetryFuncs specify the different ways to retry based on the upstream. RetryFuncConsul RetryFunc RetryFuncDefault RetryFunc RetryFuncVault RetryFunc // VaultGrace is the grace period between a lease and the max TTL for which // Consul Template will generate a new secret instead of renewing an existing // one. VaultGrace time.Duration }
type View ¶
type View struct {
// 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(i *NewViewInput) (*View, error)
NewView constructs a new view with the given inputs.
func (*View) Data ¶
func (v *View) Data() interface{}
Data returns the most-recently-received data from Consul for this View.
func (*View) DataAndLastIndex ¶ added in v0.15.0
DataAndLastIndex returns the most-recently-received data from Consul for this view, along with the last index. This is atomic so you will get the index that goes with the data you are fetching.
func (*View) Dependency ¶
func (v *View) Dependency() dep.Dependency
Dependency returns the dependency attached to this View.
type Watcher ¶
Watcher is a top-level manager for views that poll Consul for data.
func NewWatcher ¶
func NewWatcher(i *NewWatcherInput) (*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) DataCh ¶
DataCh returns a read-only channel of Views which is populated when a view receives data from its upstream.
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.