Define EtcdErrorCode as constant and reuse EtcdError instances

This commit is contained in:
Kouhei Ueno
2014-07-15 20:48:06 +09:00
parent 314eb1ae2d
commit bba23e28c2
5 changed files with 28 additions and 26 deletions

View File

@@ -25,6 +25,16 @@ import (
"github.com/coreos/go-etcd/etcd"
)
const (
EtcdErrorCodeNotFound = 100
EtcdErrorCodeValueRequired = 200
)
var (
EtcdErrorNotFound = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNotFound}
EtcdErrorValueRequired = &etcd.EtcdError{ErrorCode: EtcdErrorCodeValueRequired}
)
// EtcdClient is an injectable interface for testing.
type EtcdClient interface {
AddChild(key, data string, ttl uint64) (*etcd.Response, error)