Documentation ¶
Index ¶
Constants ¶
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 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 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) RunWithClientAndLogger ¶ added in v1.2.0
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
Run is used to run a 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
func (h WaitHashVal) Next(previous BlockingParamVal) BlockingParamVal
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.