watcher

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 4 Imported by: 7

README

Consul K/V Watcher

A simple wrapper around Consul API to watch for changes in a specific K/V directory or changes on one key. Uses blocking queries and cache by default. It also implements a simple exponential backoff for retryable errors.

Documentation

Index

Constants

View Source
const DefaultWaitTime = 10 * time.Minute

DefaultWaitTime is the maximum wait time allowed by Consul

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher is a wrapper around the Consul client that watches for changes to a keys and directories

func New

func New(consulClient *consul.Client, retryTime time.Duration, debounceTime time.Duration) *Watcher

New returns a new Watcher

func (*Watcher) WatchKey added in v1.1.0

func (w *Watcher) WatchKey(ctx context.Context, key string) (<-chan *consul.KVPair, error)

WatchKey watches for changes to a key and emits a key value pair

func (*Watcher) WatchTree

func (w *Watcher) WatchTree(ctx context.Context, path string) (<-chan consul.KVPairs, error)

WatchTree watches for changes to a directory and emit key value pairs

Jump to

Keyboard shortcuts

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