项目作者: igor-kupczynski

项目描述 :
Zookeeper znode tree recursive walker
高级语言: Go
项目地址: git://github.com/igor-kupczynski/zkwalker.git
创建时间: 2020-12-27T16:55:29Z
项目社区:https://github.com/igor-kupczynski/zkwalker

开源协议:MIT License

下载


zkwalker

Build status badge

ZkWalker is a recursive zookeeper znode tree walker.

It can be used as a command, or as a library from a go project.

Use as a command

Install the command:

  1. $ go get github.com/igor-kupczynski/zkwalker/cmd/zkwalker

Help:

  1. $ zkwalker -help
  2. Usage of zkwalker:
  3. -auth string
  4. <username:password> to use as a digest ACL
  5. -print
  6. print the znode content as string
  7. -root string
  8. znode from which to start the walk (default "/")
  9. connection-string
  10. comma separated list of zookeeper servers to connect to: host1:port1,...,hostN:portN

Print znode tree with the content of each of the znodes:

  1. $ zkwalker -auth root:password -print -root /v1 1.2.3.4:2191
  2. /v1
  3. {}
  4. /v1/foo
  5. {}
  6. /v1/foo/xyz
  7. {"xyz": true}
  8. /v1/bar
  9. {}
  10. /v1/bar/abc
  11. {"abc": true}

Use as a library

The command zkwalker offers a usage example.

Import the package:

  1. import "github.com/igor-kupczynski/zkwalker/zkwalker"

Connect to your zookeeper ensemble:

  1. walker, err := zkwalker.Connect(servers, ..)

Call Walk(...). ZnodeProcessor is a function called on each visited znode, while ChildrenProcessor allows customising which children to visit.

  1. err := walker.Walk(root, nodeFn, zkwalker.AllChildren)