Skip to content

Commit

Permalink
update docs, demo CreateDir
Browse files Browse the repository at this point in the history
  • Loading branch information
jaten committed Feb 5, 2016
1 parent 5b7a247 commit c932f0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ func (z *Client) Delete(path string, version int32) (err error) {
// Get returns the contents of a znode.
// z.Cfg.Chroot will be prepended to a relative path. The call will be retried.
func (z *Client) Get(path string) (d []byte, s *zk.Stat, err error) {
q("Get called, path = '%s'", path)
path = z.fullpath(path)
q("in Get, after fullpath() path = '%s'", path)
z.Cfg.Retry("get", path, func() error {
q("Get on path='%s'\n", path)
d, s, err = z.Conn.Get(path)
Expand All @@ -270,7 +272,9 @@ func (z *Client) GetW(path string) (d []byte, s *zk.Stat, ch <-chan zk.Event, er
// Set writes content in an existent znode.
// z.Cfg.Chroot will be prepended to a relative path. The call will be retried.
func (z *Client) Set(path string, data []byte, version int32) (s *zk.Stat, err error) {
q("Set called, path = '%s'", path)
path = z.fullpath(path)
q("in Set, after fullpath() path = '%s'", path)
z.Cfg.Retry("set", path, func() error {
q("Set on path='%s'\n", path)
s, err = z.Conn.Set(path, data, version)
Expand Down
13 changes: 6 additions & 7 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ func Test001ClientRetryGetsDefault(t *testing.T) {
func ExampleClient() {
newURL := "http://my-new-url.org:343/hello/enhanced-zookeeper-client"

base := "/chroot"
nsTest := "/service-name"
subdir := "/config"
path := nsTest + subdir + "/server-url-list"
base := "/chroot/"
path := "/service-name/config/server-url-list"
zkCfg := ClientConfig{
Servers: []string{"127.0.0.1:2181"},
Acl: zook.WorldACL(zook.PermAll),
Expand All @@ -40,9 +38,10 @@ func ExampleClient() {

defer zk.Close()

zk.CreateNode(nsTest)
zk.CreateNode(nsTest + subdir)
zk.CreateNode(path)
err = zk.CreateDir(path, nil)
if err != nil {
panic(err)
}

err = zk.DeleteNode(path) // delete any old value
if err != nil {
Expand Down

0 comments on commit c932f0f

Please sign in to comment.