[VOL-2735]Durations should be specified as type time.Duration not int
Change-Id: Id1dbecc231b0708334723decbc943a57a60d8f1d
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index a7f7730..8f6271d 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -26,6 +26,7 @@
"strconv"
"strings"
"sync"
+ "time"
"github.com/opencord/voltha-lib-go/v3/pkg/db"
"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
@@ -37,7 +38,7 @@
const (
// KvstoreTimeout specifies the time out for KV Store Connection
- KvstoreTimeout = 5
+ KvstoreTimeout = 5 * time.Second
// BasePathKvStore - service/voltha/openolt/<device_id>
BasePathKvStore = "service/voltha/openolt/{%s}"
// TpIDPathSuffix - <(pon_id, onu_id, uni_id)>/tp_id
@@ -124,13 +125,13 @@
flowIDToGemInfoLock sync.RWMutex
}
-func newKVClient(storeType string, address string, timeout uint32) (kvstore.Client, error) {
+func newKVClient(storeType string, address string, timeout time.Duration) (kvstore.Client, error) {
logger.Infow("kv-store-type", log.Fields{"store": storeType})
switch storeType {
case "consul":
- return kvstore.NewConsulClient(address, int(timeout))
+ return kvstore.NewConsulClient(address, timeout)
case "etcd":
- return kvstore.NewEtcdClient(address, int(timeout), log.FatalLevel)
+ return kvstore.NewEtcdClient(address, timeout, log.FatalLevel)
}
return nil, errors.New("unsupported-kv-store")
}
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index 18074cc..2dd75ef 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -202,7 +202,7 @@
}
// Reserve mock function implementation for KVClient
-func (kvclient *MockResKVClient) Reserve(ctx context.Context, key string, value interface{}, ttl int64) (interface{}, error) {
+func (kvclient *MockResKVClient) Reserve(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error) {
return nil, errors.New("key didn't find")
}
@@ -227,7 +227,7 @@
}
// AcquireLock mock function implementation for KVClient
-func (kvclient *MockResKVClient) AcquireLock(ctx context.Context, lockName string, timeout int) error {
+func (kvclient *MockResKVClient) AcquireLock(ctx context.Context, lockName string, timeout time.Duration) error {
return nil
}
@@ -1038,7 +1038,7 @@
type args struct {
storeType string
address string
- timeout uint32
+ timeout time.Duration
}
var kvClient kvstore.Client
tests := []struct {