diff --git a/.travis.yml b/.travis.yml index 0b50a02e..dbf78e0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ sudo: false before_install: # Symlink below is needed for Travis CI to work correctly on personal forks of libkv - - ln -s $HOME/gopath/src/github.com/${TRAVIS_REPO_SLUG///libkv/} $HOME/gopath/src/github.com/docker + - ln -s $HOME/gopath/src/github.com/${TRAVIS_REPO_SLUG///libkv/} $HOME/gopath/src/github.com/rpcxio - go get golang.org/x/tools/cmd/cover - go get github.com/mattn/goveralls - go get github.com/golang/lint/golint diff --git a/README.md b/README.md index ff2cc446..2b25d0d7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # libkv -[![GoDoc](https://godoc.org/github.com/docker/libkv?status.png)](https://godoc.org/github.com/docker/libkv) +[![GoDoc](https://godoc.org/github.com/rpcxio/libkv?status.png)](https://godoc.org/github.com/docker/libkv) [![Build Status](https://travis-ci.org/docker/libkv.svg?branch=master)](https://travis-ci.org/docker/libkv) [![Coverage Status](https://coveralls.io/repos/docker/libkv/badge.svg)](https://coveralls.io/r/docker/libkv) -[![Go Report Card](https://goreportcard.com/badge/github.com/docker/libkv)](https://goreportcard.com/report/github.com/docker/libkv) +[![Go Report Card](https://goreportcard.com/badge/github.com/rpcxio/libkv)](https://goreportcard.com/report/github.com/docker/libkv) `libkv` provides a `Go` native library to store metadata. @@ -11,7 +11,7 @@ The goal of `libkv` is to abstract common store operations for multiple distribu For example, you can use it to store your metadata or for service discovery to register machines and endpoints inside your cluster. -You can also easily implement a generic *Leader Election* on top of it (see the [docker/leadership](https://github.com/docker/leadership) repository). +You can also easily implement a generic *Leader Election* on top of it (see the [docker/leadership](https://github.com/rpcxio/leadership) repository). As of now, `libkv` offers support for `Consul`, `Etcd`, `Zookeeper` (**Distributed** store) and `BoltDB` (**Local** store). @@ -100,7 +100,7 @@ Only `Consul` and `etcd` have support for TLS and you should build and provide y ## Contributing -Want to hack on libkv? [Docker's contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) apply. +Want to hack on libkv? [Docker's contributions guidelines](https://github.com/rpcxio/docker/blob/master/CONTRIBUTING.md) apply. ## Copyright and license diff --git a/docs/examples.md b/docs/examples.md index 09752db1..06a4c3fb 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -12,9 +12,9 @@ import ( "time" "log" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/consul" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" + "github.com/rpcxio/libkv/store/consul" ) func init() { diff --git a/libkv.go b/libkv.go index bdb8c752..393f26b2 100644 --- a/libkv.go +++ b/libkv.go @@ -5,7 +5,7 @@ import ( "sort" "strings" - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv/store" ) // Initialize creates a new Store object, initializing the client diff --git a/libkv_test.go b/libkv_test.go index fe7af6b0..0c1a64f5 100644 --- a/libkv_test.go +++ b/libkv_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv/store" "github.com/stretchr/testify/assert" ) diff --git a/script/.validate b/script/.validate index 3767f422..65c4ed6d 100644 --- a/script/.validate +++ b/script/.validate @@ -4,7 +4,7 @@ if [ -z "$VALIDATE_UPSTREAM" ]; then # this is kind of an expensive check, so let's not do this twice if we # are running more than one validate bundlescript - VALIDATE_REPO='https://github.com/docker/libkv.git' + VALIDATE_REPO='https://github.com/rpcxio/libkv.git' VALIDATE_BRANCH='master' if [ "$TRAVIS" = 'true' -a "$TRAVIS_PULL_REQUEST" != 'false' ]; then diff --git a/store/boltdb/boltdb.go b/store/boltdb/boltdb.go index d62979cb..d5263f13 100644 --- a/store/boltdb/boltdb.go +++ b/store/boltdb/boltdb.go @@ -10,8 +10,8 @@ import ( "sync/atomic" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" bolt "go.etcd.io/bbolt" ) diff --git a/store/boltdb/boltdb_test.go b/store/boltdb/boltdb_test.go index 3eb4e84b..9c3f04c1 100644 --- a/store/boltdb/boltdb_test.go +++ b/store/boltdb/boltdb_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/testutils" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" + "github.com/rpcxio/libkv/testutils" "github.com/stretchr/testify/assert" ) diff --git a/store/consul/consul.go b/store/consul/consul.go index cb64be72..30278847 100644 --- a/store/consul/consul.go +++ b/store/consul/consul.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" api "github.com/hashicorp/consul/api" ) diff --git a/store/consul/consul_test.go b/store/consul/consul_test.go index 232336a8..6d4cd5f1 100644 --- a/store/consul/consul_test.go +++ b/store/consul/consul_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/testutils" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" + "github.com/rpcxio/libkv/testutils" "github.com/stretchr/testify/assert" ) diff --git a/store/etcd/etcd.go b/store/etcd/etcd.go index ec407b07..ac23754c 100644 --- a/store/etcd/etcd.go +++ b/store/etcd/etcd.go @@ -11,8 +11,8 @@ import ( "time" etcd "github.com/coreos/etcd/client" - "github.com/docker/libkv" - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" ) var ( diff --git a/store/etcd/etcd_test.go b/store/etcd/etcd_test.go index 767afd04..46fb5910 100644 --- a/store/etcd/etcd_test.go +++ b/store/etcd/etcd_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/testutils" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" + "github.com/rpcxio/libkv/testutils" "github.com/stretchr/testify/assert" ) diff --git a/store/mock/mock.go b/store/mock/mock.go index 82a5b03b..fdc74f8b 100644 --- a/store/mock/mock.go +++ b/store/mock/mock.go @@ -1,7 +1,7 @@ package mock import ( - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv/store" "github.com/stretchr/testify/mock" ) diff --git a/store/zookeeper/zookeeper.go b/store/zookeeper/zookeeper.go index ff8d4ebe..9af5fd05 100644 --- a/store/zookeeper/zookeeper.go +++ b/store/zookeeper/zookeeper.go @@ -4,8 +4,8 @@ import ( "strings" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" zk "github.com/samuel/go-zookeeper/zk" ) @@ -290,8 +290,12 @@ func (s *Zookeeper) DeleteTree(directory string) error { // AtomicPut put a value at "key" if the key has not been // modified in the meantime, throws an error if this is the case -func (s *Zookeeper) AtomicPut(key string, value []byte, previous *store.KVPair, _ *store.WriteOptions) (bool, *store.KVPair, error) { +func (s *Zookeeper) AtomicPut(key string, value []byte, previous *store.KVPair, opts *store.WriteOptions) (bool, *store.KVPair, error) { var lastIndex uint64 + var flag int32 + if opts != nil && opts.TTL > 0 { + flag = zk.FlagEphemeral + } if previous != nil { meta, err := s.client.Set(s.normalize(key), value, int32(previous.LastIndex)) @@ -305,7 +309,7 @@ func (s *Zookeeper) AtomicPut(key string, value []byte, previous *store.KVPair, lastIndex = uint64(meta.Version) } else { // Interpret previous == nil as create operation. - _, err := s.client.Create(s.normalize(key), value, 0, zk.WorldACL(zk.PermAll)) + _, err := s.client.Create(s.normalize(key), value, flag, zk.WorldACL(zk.PermAll)) if err != nil { // Directory does not exist if err == zk.ErrNoNode { @@ -319,7 +323,7 @@ func (s *Zookeeper) AtomicPut(key string, value []byte, previous *store.KVPair, } // Create the node - if _, err := s.client.Create(s.normalize(key), value, 0, zk.WorldACL(zk.PermAll)); err != nil { + if _, err := s.client.Create(s.normalize(key), value, flag, zk.WorldACL(zk.PermAll)); err != nil { // Node exist error (when previous nil) if err == zk.ErrNodeExists { return false, nil, store.ErrKeyExists diff --git a/store/zookeeper/zookeeper_test.go b/store/zookeeper/zookeeper_test.go index 36d17597..9dd99f8f 100644 --- a/store/zookeeper/zookeeper_test.go +++ b/store/zookeeper/zookeeper_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/testutils" + "github.com/rpcxio/libkv" + "github.com/rpcxio/libkv/store" + "github.com/rpcxio/libkv/testutils" "github.com/stretchr/testify/assert" ) diff --git a/testutils/utils.go b/testutils/utils.go index 842d9536..1132c594 100644 --- a/testutils/utils.go +++ b/testutils/utils.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/docker/libkv/store" + "github.com/rpcxio/libkv/store" "github.com/stretchr/testify/assert" )