Notify user of supported backend storage
Signed-off-by: Chun Chen <ramichen@tencent.com>
This commit is contained in:
parent
0dda8605e6
commit
6b43181cfa
2 changed files with 14 additions and 2 deletions
|
@ -20,7 +20,7 @@ const (
|
|||
|
||||
var (
|
||||
// ErrNotSupported is thrown when the backend k/v store is not supported by libkv
|
||||
ErrNotSupported = errors.New("Backend storage not supported yet, please choose another one")
|
||||
ErrNotSupported = errors.New("Backend storage not supported yet, please choose one of")
|
||||
// ErrNotImplemented is thrown when a method is not implemented by the current backend
|
||||
ErrNotImplemented = errors.New("Call not implemented in current backend")
|
||||
// ErrNotReachable is thrown when the API cannot be reached for issuing common store operations
|
||||
|
|
|
@ -62,6 +62,10 @@
|
|||
package libkv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/libkv/store"
|
||||
"github.com/docker/libkv/store/consul"
|
||||
"github.com/docker/libkv/store/etcd"
|
||||
|
@ -78,6 +82,14 @@ var (
|
|||
store.ETCD: etcd.New,
|
||||
store.ZK: zookeeper.New,
|
||||
}
|
||||
supportedBackend = func() string {
|
||||
keys := make([]string, 0, len(initializers))
|
||||
for k := range initializers {
|
||||
keys = append(keys, string(k))
|
||||
}
|
||||
sort.Strings(keys)
|
||||
return strings.Join(keys, ", ")
|
||||
}()
|
||||
)
|
||||
|
||||
// NewStore creates a an instance of store
|
||||
|
@ -86,5 +98,5 @@ func NewStore(backend store.Backend, addrs []string, options *store.Config) (sto
|
|||
return init(addrs, options)
|
||||
}
|
||||
|
||||
return nil, store.ErrNotSupported
|
||||
return nil, fmt.Errorf("%s %s", store.ErrNotSupported.Error(), supportedBackend)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue