VOL-2154 : Moving back db/model to voltha-go
- Kept backend.go to limit impact in other components
Amendments:
- Removed db/model unit tests
- Forgot to fix some stash merges
- Removed unused "lock" parameter from kv clients
- Changed version for release
Change-Id: I25a03eb335ce22d49412be4bf2cceaff387dc4ae
diff --git a/pkg/db/kvstore/client.go b/pkg/db/kvstore/client.go
index c0ebe5f..97fbec9 100644
--- a/pkg/db/kvstore/client.go
+++ b/pkg/db/kvstore/client.go
@@ -79,10 +79,10 @@
// Client represents the set of APIs a KV Client must implement
type Client interface {
- List(key string, timeout int, lock ...bool) (map[string]*KVPair, error)
- Get(key string, timeout int, lock ...bool) (*KVPair, error)
- Put(key string, value interface{}, timeout int, lock ...bool) error
- Delete(key string, timeout int, lock ...bool) error
+ List(key string, timeout int) (map[string]*KVPair, error)
+ Get(key string, timeout int) (*KVPair, error)
+ Put(key string, value interface{}, timeout int) error
+ Delete(key string, timeout int) error
Reserve(key string, value interface{}, ttl int64) (interface{}, error)
ReleaseReservation(key string) error
ReleaseAllReservations() error
diff --git a/pkg/db/kvstore/consulclient.go b/pkg/db/kvstore/consulclient.go
index e0e8550..a94de4d 100644
--- a/pkg/db/kvstore/consulclient.go
+++ b/pkg/db/kvstore/consulclient.go
@@ -71,7 +71,7 @@
// List returns an array of key-value pairs with key as a prefix. Timeout defines how long the function will
// wait for a response
-func (c *ConsulClient) List(key string, timeout int, lock ...bool) (map[string]*KVPair, error) {
+func (c *ConsulClient) List(key string, timeout int) (map[string]*KVPair, error) {
duration := GetDuration(timeout)
kv := c.consul.KV()
@@ -92,7 +92,7 @@
// Get returns a key-value pair for a given key. Timeout defines how long the function will
// wait for a response
-func (c *ConsulClient) Get(key string, timeout int, lock ...bool) (*KVPair, error) {
+func (c *ConsulClient) Get(key string, timeout int) (*KVPair, error) {
duration := GetDuration(timeout)
@@ -115,7 +115,7 @@
// Put writes a key-value pair to the KV store. Value can only be a string or []byte since the consul API
// accepts only a []byte as a value for a put operation. Timeout defines how long the function will
// wait for a response
-func (c *ConsulClient) Put(key string, value interface{}, timeout int, lock ...bool) error {
+func (c *ConsulClient) Put(key string, value interface{}, timeout int) error {
// Validate that we can create a byte array from the value as consul API expects a byte array
var val []byte
@@ -141,7 +141,7 @@
// Delete removes a key from the KV store. Timeout defines how long the function will
// wait for a response
-func (c *ConsulClient) Delete(key string, timeout int, lock ...bool) error {
+func (c *ConsulClient) Delete(key string, timeout int) error {
kv := c.consul.KV()
var writeOptions consulapi.WriteOptions
c.writeLock.Lock()
diff --git a/pkg/db/kvstore/etcdclient.go b/pkg/db/kvstore/etcdclient.go
index 8db047c..e8bc92c 100644
--- a/pkg/db/kvstore/etcdclient.go
+++ b/pkg/db/kvstore/etcdclient.go
@@ -71,7 +71,7 @@
// List returns an array of key-value pairs with key as a prefix. Timeout defines how long the function will
// wait for a response
-func (c *EtcdClient) List(key string, timeout int, lock ...bool) (map[string]*KVPair, error) {
+func (c *EtcdClient) List(key string, timeout int) (map[string]*KVPair, error) {
duration := GetDuration(timeout)
ctx, cancel := context.WithTimeout(context.Background(), duration)
@@ -91,7 +91,7 @@
// Get returns a key-value pair for a given key. Timeout defines how long the function will
// wait for a response
-func (c *EtcdClient) Get(key string, timeout int, lock ...bool) (*KVPair, error) {
+func (c *EtcdClient) Get(key string, timeout int) (*KVPair, error) {
duration := GetDuration(timeout)
ctx, cancel := context.WithTimeout(context.Background(), duration)
@@ -112,7 +112,7 @@
// Put writes a key-value pair to the KV store. Value can only be a string or []byte since the etcd API
// accepts only a string as a value for a put operation. Timeout defines how long the function will
// wait for a response
-func (c *EtcdClient) Put(key string, value interface{}, timeout int, lock ...bool) error {
+func (c *EtcdClient) Put(key string, value interface{}, timeout int) error {
// Validate that we can convert value to a string as etcd API expects a string
var val string
@@ -155,7 +155,7 @@
// Delete removes a key from the KV store. Timeout defines how long the function will
// wait for a response
-func (c *EtcdClient) Delete(key string, timeout int, lock ...bool) error {
+func (c *EtcdClient) Delete(key string, timeout int) error {
duration := GetDuration(timeout)
@@ -233,7 +233,7 @@
}
} else {
// Read the Key to ensure this is our Key
- m, err := c.Get(key, defaultKVGetTimeout, false)
+ m, err := c.Get(key, defaultKVGetTimeout)
if err != nil {
return nil, err
}