Documentation ¶
Index ¶
- Constants
- type BlockingParamVal
- type HandlerFunc
- type HttpHandlerConfig
- type HybridHandlerFunc
- type Plan
- func (p *Plan) IsStopped() bool
- func (p *Plan) Run(address string) error
- func (p *Plan) RunWithClientAndHclog(client *consulapi.Client, logger hclog.Logger) error
- func (p *Plan) RunWithClientAndLogger(client *consulapi.Client, logger *log.Logger) errordeprecated
- func (p *Plan) RunWithConfig(address string, conf *consulapi.Config) error
- func (p *Plan) Stop()
- type WaitHashVal
- type WaitIndexVal
- type WatcherFunc
Constants ¶
const DefaultTimeout = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockingParamVal ¶
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 ¶
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 ¶
type HybridHandlerFunc ¶
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 ¶
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 Logger hclog.Logger // Deprecated: use Logger 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 ParseExempt ¶
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) RunWithClientAndHclog ¶ added in v1.4.0
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) RunWithConfig ¶
Run is used to run a watch plan
type WaitHashVal ¶
type WaitHashVal string
WaitHashVal is a type representing a Consul content hash that implements BlockingParamVal.
func (WaitHashVal) Equal ¶
func (h WaitHashVal) Equal(other BlockingParamVal) bool
Equal implements BlockingParamVal
func (WaitHashVal) Next ¶
func (h WaitHashVal) Next(previous BlockingParamVal) BlockingParamVal
Next implements BlockingParamVal
type WaitIndexVal ¶
type WaitIndexVal uint64
WaitIndexVal is a type representing a Consul index that implements BlockingParamVal.
func (WaitIndexVal) Equal ¶
func (idx WaitIndexVal) Equal(other BlockingParamVal) bool
Equal implements BlockingParamVal
func (WaitIndexVal) Next ¶
func (idx WaitIndexVal) Next(previous BlockingParamVal) BlockingParamVal
Next implements BlockingParamVal
type WatcherFunc ¶
type WatcherFunc func(*Plan) (BlockingParamVal, interface{}, error)
WatcherFunc is used to watch for a diff.