consul: github.com/hashicorp/consul/api/watch Index | Files

package watch

import "github.com/hashicorp/consul/api/watch"

Index

Package Files

funcs.go plan.go watch.go

Constants

const DefaultTimeout = 10 * time.Second

type BlockingParamVal Uses

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 customize 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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

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

func ParseExempt Uses

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 Uses

func (p *Plan) IsStopped() bool

func (*Plan) Run Uses

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

func (*Plan) RunWithClientAndHclog Uses

func (p *Plan) RunWithClientAndHclog(client *consulapi.Client, logger hclog.Logger) error

RunWithClientAndLogger runs a watch plan using an external client and hclog.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) RunWithClientAndLogger Uses

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

Deprecated: Use RunwithClientAndHclog

func (*Plan) RunWithConfig Uses

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

Run is used to run a watch plan

func (*Plan) Stop Uses

func (p *Plan) Stop()

Stop is used to stop running the watch plan

type WaitHashVal Uses

type WaitHashVal string

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

func (WaitHashVal) Equal Uses

func (h WaitHashVal) Equal(other BlockingParamVal) bool

Equal implements BlockingParamVal

func (WaitHashVal) Next Uses

func (h WaitHashVal) Next(previous BlockingParamVal) BlockingParamVal

Next implements BlockingParamVal

type WaitIndexVal Uses

type WaitIndexVal uint64

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

func (WaitIndexVal) Equal Uses

func (idx WaitIndexVal) Equal(other BlockingParamVal) bool

Equal implements BlockingParamVal

func (WaitIndexVal) Next Uses

func (idx WaitIndexVal) Next(previous BlockingParamVal) BlockingParamVal

Next implements BlockingParamVal

type WatcherFunc Uses

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

WatcherFunc is used to watch for a diff.

Package watch imports 10 packages (graph) and is imported by 57 packages. Updated 2020-06-17. Refresh now. Tools for package owners.