Vendor main dependencies.
This commit is contained in:
parent
49a09ab7dd
commit
dd5e3fba01
2738 changed files with 1045689 additions and 0 deletions
40
vendor/github.com/docker/libkv/libkv.go
generated
vendored
Normal file
40
vendor/github.com/docker/libkv/libkv.go
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
package libkv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/libkv/store"
|
||||
)
|
||||
|
||||
// Initialize creates a new Store object, initializing the client
|
||||
type Initialize func(addrs []string, options *store.Config) (store.Store, error)
|
||||
|
||||
var (
|
||||
// Backend initializers
|
||||
initializers = make(map[store.Backend]Initialize)
|
||||
|
||||
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 an instance of store
|
||||
func NewStore(backend store.Backend, addrs []string, options *store.Config) (store.Store, error) {
|
||||
if init, exists := initializers[backend]; exists {
|
||||
return init(addrs, options)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%s %s", store.ErrBackendNotSupported.Error(), supportedBackend)
|
||||
}
|
||||
|
||||
// AddStore adds a new store backend to libkv
|
||||
func AddStore(store store.Backend, init Initialize) {
|
||||
initializers[store] = init
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue