|
@@ -67,10 +67,6 @@ import (
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"github.com/docker/libkv/store"
|
|
"github.com/docker/libkv/store"
|
|
- "github.com/docker/libkv/store/boltdb"
|
|
|
|
- "github.com/docker/libkv/store/consul"
|
|
|
|
- "github.com/docker/libkv/store/etcd"
|
|
|
|
- "github.com/docker/libkv/store/zookeeper"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
// Initialize creates a new Store object, initializing the client
|
|
// Initialize creates a new Store object, initializing the client
|
|
@@ -78,12 +74,8 @@ type Initialize func(addrs []string, options *store.Config) (store.Store, error)
|
|
|
|
|
|
var (
|
|
var (
|
|
// Backend initializers
|
|
// Backend initializers
|
|
- initializers = map[store.Backend]Initialize{
|
|
|
|
- store.CONSUL: consul.New,
|
|
|
|
- store.ETCD: etcd.New,
|
|
|
|
- store.ZK: zookeeper.New,
|
|
|
|
- store.BOLTDB: boltdb.New,
|
|
|
|
- }
|
|
|
|
|
|
+ initializers = make(map[store.Backend]Initialize)
|
|
|
|
+
|
|
supportedBackend = func() string {
|
|
supportedBackend = func() string {
|
|
keys := make([]string, 0, len(initializers))
|
|
keys := make([]string, 0, len(initializers))
|
|
for k := range initializers {
|
|
for k := range initializers {
|
|
@@ -102,3 +94,8 @@ func NewStore(backend store.Backend, addrs []string, options *store.Config) (sto
|
|
|
|
|
|
return nil, fmt.Errorf("%s %s", store.ErrNotSupported.Error(), supportedBackend)
|
|
return nil, fmt.Errorf("%s %s", store.ErrNotSupported.Error(), supportedBackend)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// AddStore adds a new store backend to libkv
|
|
|
|
+func AddStore(store store.Backend, init Initialize) {
|
|
|
|
+ initializers[store] = init
|
|
|
|
+}
|