Documentation ¶
Index ¶
- Constants
- type CatalogService
- type CatalogServicesDependency
- type CatalogServicesList
- type Dependency
- type FileDependency
- type KeyDependency
- type KeyPair
- type KeyPrefixDependency
- type Node
- type NodesDependency
- type RetryFunc
- type Service
- type ServiceDependency
- type ServiceList
- type ServiceStatusFilter
- type ServiceTags
- type View
- type Wait
- type Watcher
Constants ¶
const ( HealthAny = "any" HealthUnknown = "unknown" HealthPassing = "passing" HealthWarning = "warning" HealthCritical = "critical" )
Ripped from https://github.com/hashicorp/consul/blob/master/consul/structs/structs.go#L31
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatalogService ¶ added in v0.5.0
CatalogService is a catalog entry in Consul.
type CatalogServicesDependency ¶ added in v0.5.0
type CatalogServicesDependency struct { Name string Tags []string DataCenter string // contains filtered or unexported fields }
CatalogServicesDependency is the representation of a requested catalog service dependency from inside a template.
func ParseCatalogServicesDependency ¶ added in v0.5.0
func ParseCatalogServicesDependency(s ...string) (*CatalogServicesDependency, error)
ParseCatalogServicesDependency parses a string of the format @dc.
func (*CatalogServicesDependency) Display ¶ added in v0.5.0
func (d *CatalogServicesDependency) Display() string
Display returns a string that should be displayed to the user in output (for example).
func (*CatalogServicesDependency) Fetch ¶ added in v0.5.0
func (d *CatalogServicesDependency) Fetch(client *api.Client, options *api.QueryOptions) (interface{}, *api.QueryMeta, error)
Fetch queries the Consul API defined by the given client and returns a slice of CatalogService objects.
func (*CatalogServicesDependency) HashCode ¶ added in v0.5.0
func (d *CatalogServicesDependency) HashCode() string
HashCode returns the hash code for this dependency.
func (*CatalogServicesDependency) Key ¶ added in v0.5.0
func (d *CatalogServicesDependency) Key() string
Key returns the key given by the user in the template.
type CatalogServicesList ¶ added in v0.5.0
type CatalogServicesList []*CatalogService
CatalogServicesList is a sortable slice of CatalogService structs.
func (CatalogServicesList) Len ¶ added in v0.5.0
func (s CatalogServicesList) Len() int
func (CatalogServicesList) Less ¶ added in v0.5.0
func (s CatalogServicesList) Less(i, j int) bool
func (CatalogServicesList) Swap ¶ added in v0.5.0
func (s CatalogServicesList) Swap(i, j int)
type Dependency ¶
type Dependency interface { Fetch(*api.Client, *api.QueryOptions) (interface{}, *api.QueryMeta, error) HashCode() string Key() string Display() string }
Dependency is an interface for a dependency that Consul Template is capable of watching.
type FileDependency ¶
type FileDependency struct {
// contains filtered or unexported fields
}
func ParseFileDependency ¶
func ParseFileDependency(s string) (*FileDependency, error)
func (*FileDependency) Display ¶
func (d *FileDependency) Display() string
func (*FileDependency) Fetch ¶
func (d *FileDependency) Fetch(client *api.Client, options *api.QueryOptions) (interface{}, *api.QueryMeta, error)
func (*FileDependency) HashCode ¶
func (d *FileDependency) HashCode() string
func (*FileDependency) Key ¶
func (d *FileDependency) Key() string
type KeyDependency ¶
type KeyDependency struct { Path string DataCenter string // contains filtered or unexported fields }
from inside a template.
func ParseKeyDependency ¶
func ParseKeyDependency(s string) (*KeyDependency, error)
ParseKeyDependency parses a string of the format a(/b(/c...))
func (*KeyDependency) Display ¶
func (d *KeyDependency) Display() string
func (*KeyDependency) Fetch ¶
func (d *KeyDependency) Fetch(client *api.Client, options *api.QueryOptions) (interface{}, *api.QueryMeta, error)
Fetch queries the Consul API defined by the given client and returns string of the value to Path.
func (*KeyDependency) HashCode ¶
func (d *KeyDependency) HashCode() string
func (*KeyDependency) Key ¶
func (d *KeyDependency) Key() string
type KeyPrefixDependency ¶
type KeyPrefixDependency struct { Prefix string DataCenter string // contains filtered or unexported fields }
KeyPrefixDependency is the representation of a requested key dependency from inside a template.
func ParseKeyPrefixDependency ¶
func ParseKeyPrefixDependency(s string) (*KeyPrefixDependency, error)
ParseKeyPrefixDependency parses a string of the format a(/b(/c...))
func (*KeyPrefixDependency) Display ¶
func (d *KeyPrefixDependency) Display() string
func (*KeyPrefixDependency) Fetch ¶
func (d *KeyPrefixDependency) Fetch(client *api.Client, options *api.QueryOptions) (interface{}, *api.QueryMeta, error)
Fetch queries the Consul API defined by the given client and returns a slice of KeyPair objects
func (*KeyPrefixDependency) HashCode ¶
func (d *KeyPrefixDependency) HashCode() string
func (*KeyPrefixDependency) Key ¶
func (d *KeyPrefixDependency) Key() string
type NodesDependency ¶ added in v0.5.0
type NodesDependency struct { DataCenter string // contains filtered or unexported fields }
func ParseNodesDependency ¶ added in v0.5.0
func ParseNodesDependency(s ...string) (*NodesDependency, error)
ParseNodesDependency parses a string of the format @dc.
func (*NodesDependency) Display ¶ added in v0.5.0
func (d *NodesDependency) Display() string
func (*NodesDependency) Fetch ¶ added in v0.5.0
func (d *NodesDependency) Fetch(client *api.Client, options *api.QueryOptions) (interface{}, *api.QueryMeta, error)
Fetch queries the Consul API defined by the given client and returns a slice of Node objects
func (*NodesDependency) HashCode ¶ added in v0.5.0
func (d *NodesDependency) HashCode() string
func (*NodesDependency) Key ¶ added in v0.5.0
func (d *NodesDependency) Key() string
type RetryFunc ¶ added in v0.5.0
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 Service ¶
type Service struct { Node string Address string ID string Name string Tags ServiceTags Port uint64 }
Service is a service entry in Consul
type ServiceDependency ¶
type ServiceDependency struct { Name string Tag string DataCenter string Port uint64 Status ServiceStatusFilter // contains filtered or unexported fields }
from inside a template.
func ParseServiceDependency ¶
func ParseServiceDependency(s ...string) (*ServiceDependency, error)
ParseServiceDependency processes the incoming strings to build a service dependency.
Supported arguments
ParseServiceDependency("service_id") ParseServiceDependency("service_id", "health_check")
Where service_id is in the format of service(.tag(@datacenter(:port))) and health_check is either "any" or "passing".
If no health_check is provided then its the same as "passing".
func (*ServiceDependency) Display ¶
func (d *ServiceDependency) Display() string
func (*ServiceDependency) Fetch ¶
func (d *ServiceDependency) Fetch(client *api.Client, options *api.QueryOptions) (interface{}, *api.QueryMeta, error)
Fetch queries the Consul API defined by the given client and returns a slice of Service objects.
func (*ServiceDependency) HashCode ¶
func (d *ServiceDependency) HashCode() string
func (*ServiceDependency) Key ¶
func (d *ServiceDependency) Key() string
type ServiceList ¶
type ServiceList []*Service
ServiceList is a sortable slice of Service
func (ServiceList) Len ¶
func (s ServiceList) Len() int
func (ServiceList) Less ¶
func (s ServiceList) Less(i, j int) bool
func (ServiceList) Swap ¶
func (s ServiceList) Swap(i, j int)
type ServiceStatusFilter ¶ added in v0.3.0
type ServiceStatusFilter []string
ServiceStatusFilter is used to specify a list of service statuses that you want filter by.
func (ServiceStatusFilter) String ¶ added in v0.3.0
func (f ServiceStatusFilter) String() string
type ServiceTags ¶ added in v0.3.0
type ServiceTags []string
ServiceTags is a slice of tags assigned to a Service
func (ServiceTags) Contains ¶ added in v0.3.0
func (t ServiceTags) Contains(s string) bool
Contains returns true if the tags exists in the ServiceTags slice.
type View ¶ added in v0.5.0
type View struct { Dependency Dependency Data interface{} // contains filtered or unexported fields }
View is a representation of a Dependency and the most recent data it has received from Consul.
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 ¶
func NewWatcher(client *api.Client, dependencies []Dependency) (*Watcher, error)
func (*Watcher) SetRetry ¶ added in v0.5.0
SetRetry is used to set the retry to a static value. See SetRetryFunc for more informatoin.
func (*Watcher) SetRetryFunc ¶ added in v0.5.0
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) Watch ¶
Watch creates a series of Consul views which poll for data in parallel. If the `once` flag is true, each view will return data (or an error) exactly once and terminate. If the `once` flag is false, views will continue to poll indefinitely unless they encounter an irrecoverable error.