util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2014 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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 Dependency

type Dependency interface {
	Fetch(*api.Client, *api.QueryOptions) (interface{}, *api.QueryMeta, error)
	HashCode() string
	Key() string
	Display() string
}

Dependency is an interface

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
}

KeyDependency is the representation of a requested key dependency 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 KeyPair

type KeyPair struct {
	Path  string
	Key   string
	Value string
}

KeyPair is a simple Key-Value pair

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)

ParseKeyDependency 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 Node added in v0.3.0

type Node struct {
	Node    string
	Address string
}

Node is a node entry in Consul

type NodeDependency added in v0.3.0

type NodeDependency struct {
	DataCenter string
	// contains filtered or unexported fields
}

NodeDependency is the representation of requested nodes from Consul

func ParseNodeDependency added in v0.3.0

func ParseNodeDependency(s ...string) (*NodeDependency, error)

ParseKeyDependency parses a string of the format a(/b(/c...))

func (*NodeDependency) Display added in v0.3.0

func (d *NodeDependency) Display() string

func (*NodeDependency) Fetch added in v0.3.0

func (d *NodeDependency) 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 (*NodeDependency) HashCode added in v0.3.0

func (d *NodeDependency) HashCode() string

func (*NodeDependency) Key added in v0.3.0

func (d *NodeDependency) Key() string

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
}

ServiceDependency is the representation of a requested service dependency 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 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 WatchData

type WatchData struct {
	Dependency Dependency
	Data       interface{}
	// contains filtered or unexported fields
}

func NewWatchData

func NewWatchData(dependency Dependency) (*WatchData, error)

func (*WatchData) Display

func (wd *WatchData) Display() string

type Watcher

type Watcher struct {
	// DataCh is the chan where new WatchData will be published
	DataCh chan *WatchData

	// 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) Stop

func (w *Watcher) Stop()

func (*Watcher) Watch

func (w *Watcher) Watch(once bool)

Jump to

Keyboard shortcuts

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