watch

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 10 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockingParamVal added in v1.2.0

type BlockingParamVal interface {
	// Equal returns whether the other param value should be considered equal
	// (i.e. representing no change in the watched resource). Equal must not panic
	// if other is nil.
	Equal(other BlockingParamVal) bool

	// Next is called when deciding which value to use on the next blocking call.
	// It assumes the BlockingParamVal value it is called on is the most recent one
	// returned and passes the previous one which may be nil as context. This
	// allows types to customise logic around ordering without assuming there is
	// an order. For example WaitIndexVal can check that the index didn't go
	// backwards and if it did then reset to 0. Most other cases should just
	// return themselves (the most recent value) to be used in the next request.
	Next(previous BlockingParamVal) BlockingParamVal
}

BlockingParamVal is an interface representing the common operations needed for different styles of blocking. It's used to abstract the core watch plan from whether we are performing index-based or hash-based blocking.

type HandlerFunc

type HandlerFunc func(uint64, interface{})

HandlerFunc is used to handle new data. It only works for index-based watches (which is almost all end points currently) and is kept for backwards compatibility until more places can make use of hash-based watches too.

type HttpHandlerConfig added in v1.0.1

type HttpHandlerConfig struct {
	Path          string              `mapstructure:"path"`
	Method        string              `mapstructure:"method"`
	Timeout       time.Duration       `mapstructure:"-"`
	TimeoutRaw    string              `mapstructure:"timeout"`
	Header        map[string][]string `mapstructure:"header"`
	TLSSkipVerify bool                `mapstructure:"tls_skip_verify"`
}

type HybridHandlerFunc added in v1.2.0

type HybridHandlerFunc func(BlockingParamVal, interface{})

HybridHandlerFunc is used to handle new data. It can support either index-based or hash-based watches via the BlockingParamVal.

type Plan added in v0.8.2

type Plan struct {
	Datacenter  string
	Token       string
	Type        string
	HandlerType string
	Exempt      map[string]interface{}

	Watcher WatcherFunc
	// Handler is kept for backward compatibility but only supports watches based
	// on index param. To support hash based watches, set HybridHandler instead.
	Handler       HandlerFunc
	HybridHandler HybridHandlerFunc
	LogOutput     io.Writer
	// contains filtered or unexported fields
}

Plan is the parsed version of a watch specification. A watch provides the details of a query, which generates a view into the Consul data store. This view is watched for changes and a handler is invoked to take any appropriate actions.

func Parse

func Parse(params map[string]interface{}) (*Plan, error)

Parse takes a watch query and compiles it into a WatchPlan or an error

func ParseExempt

func ParseExempt(params map[string]interface{}, exempt []string) (*Plan, error)

ParseExempt takes a watch query and compiles it into a WatchPlan or an error Any exempt parameters are stored in the Exempt map

func (*Plan) IsStopped added in v0.8.5

func (p *Plan) IsStopped() bool

func (*Plan) Run added in v0.8.2

func (p *Plan) Run(address string) error

func (*Plan) RunWithClientAndLogger added in v1.2.0

func (p *Plan) RunWithClientAndLogger(client *consulapi.Client,
	logger *log.Logger) error

RunWithClientAndLogger runs a watch plan using an external client and log.Logger instance. Using this, the plan's Datacenter, Token and LogOutput fields are ignored and the passed client is expected to be configured as needed.

func (*Plan) RunWithConfig added in v1.2.0

func (p *Plan) RunWithConfig(address string, conf *consulapi.Config) error

Run is used to run a watch plan

func (*Plan) Stop added in v0.8.2

func (p *Plan) Stop()

Stop is used to stop running the watch plan

type WaitHashVal added in v1.2.0

type WaitHashVal string

WaitHashVal is a type representing a Consul content hash that implements BlockingParamVal.

func (WaitHashVal) Equal added in v1.2.0

func (h WaitHashVal) Equal(other BlockingParamVal) bool

Equal implements BlockingParamVal

func (WaitHashVal) Next added in v1.2.0

Next implements BlockingParamVal

type WaitIndexVal added in v1.2.0

type WaitIndexVal uint64

WaitIndexVal is a type representing a Consul index that implements BlockingParamVal.

func (WaitIndexVal) Equal added in v1.2.0

func (idx WaitIndexVal) Equal(other BlockingParamVal) bool

Equal implements BlockingParamVal

func (WaitIndexVal) Next added in v1.2.0

func (idx WaitIndexVal) Next(previous BlockingParamVal) BlockingParamVal

Next implements BlockingParamVal

type WatcherFunc added in v0.8.2

type WatcherFunc func(*Plan) (BlockingParamVal, interface{}, error)

WatcherFunc is used to watch for a diff.

Jump to

Keyboard shortcuts

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