Documentation ¶
Overview ¶
Package zkwatcher provides an easy way to recursively watch a zookeeper path with meaningful events.
Example ¶
package main import ( "fmt" "log" "time" "github.com/agrarianlabs/zkwatcher" "github.com/samuel/go-zookeeper/zk" ) func main() { conn, _, err := zk.Connect([]string{"zookeeper host addr"}, 10*time.Second) if err != nil { log.Fatal(err) } defer conn.Close() watcher := zkwatcher.NewWatcher(conn) defer func() { _ = watcher.Close() }() // Make sure the path exists before starting the watcher. if err := watcher.Watch("/path/to/watch"); err != nil { log.Println(err) return } for event := range watcher.C { if event.Error != nil { log.Println(err) return } fmt.Printf("%s on %s\n", event.Type, event.Path) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventType ¶
type EventType int
EventType enum type.
const ( Create EventType Delete Update )
EventType enum values.
type Stats ¶
type Stats struct { Depth int `json:"depth"` Cap int `json:"cap"` Goroutines int `json:"goroutines"` Running bool `json:"running"` WatchedNodes []string `json:"watched_nodes"` WatchedChildren []string `json:"watched_children"` }
Stats contains all runtime data from the watcher.
type Watcher ¶
type Watcher struct { C <-chan Event // Exposed read channel // contains filtered or unexported fields }
Watcher provides a read-only chan `C` where all the watched events are sent to.
func NewWatcher ¶
NewWatcher initializes a watcher. It is the caller responsibility to Close it.
Directories ¶
Path | Synopsis |
---|---|
Godeps
|
|
_workspace/src/github.com/samuel/go-zookeeper/zk
Package zk is a native Go client library for the ZooKeeper orchestration service.
|
Package zk is a native Go client library for the ZooKeeper orchestration service. |
Click to show internal directories.
Click to hide internal directories.