From: Marco Tallskog Date: Fri, 3 May 2019 08:45:22 +0000 (+0300) Subject: Fix Close API call X-Git-Tag: v0.0.2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Ftags%2Fv0.0.2;hp=7c17df52f1e8004e68bcc2d339be5d1347625aa6;p=ric-plt%2Fsdlgo.git Fix Close API call Calling Close function from API caused a recursive call to itself as the underlying module was using a function with same name. Rename the internal close function to avoid this. Change-Id: I05c3ca8e79fb5f30cae81917f56efacbd1797768 Signed-off-by: Marco Tallskog --- diff --git a/internal/sdlgoredis/sdlgoredis.go b/internal/sdlgoredis/sdlgoredis.go index 01fe5f7..10b1bfe 100644 --- a/internal/sdlgoredis/sdlgoredis.go +++ b/internal/sdlgoredis/sdlgoredis.go @@ -67,7 +67,7 @@ func Create() *DB { return &db } -func (db *DB) Close() error { +func (db *DB) CloseDB() error { return db.client.Close() } diff --git a/sdl.go b/sdl.go index 04e0625..295d21e 100644 --- a/sdl.go +++ b/sdl.go @@ -27,7 +27,7 @@ import ( type iDatabase interface { MSet(pairs ...interface{}) error MGet(keys []string) ([]interface{}, error) - Close() error + CloseDB() error Del(keys []string) error Keys(key string) ([]string, error) SetIE(key string, oldData, newData interface{}) (bool, error) @@ -62,7 +62,7 @@ func NewSdlInstance(NameSpace string, db iDatabase) *SdlInstance { } func (s *SdlInstance) Close() error { - return s.Close() + return s.CloseDB() } func (s *SdlInstance) setNamespaceToKeys(pairs ...interface{}) []interface{} { diff --git a/sdl_test.go b/sdl_test.go index 75ee321..dbd073f 100644 --- a/sdl_test.go +++ b/sdl_test.go @@ -40,7 +40,7 @@ func (m *mockDB) MGet(keys []string) ([]interface{}, error) { return a.Get(0).([]interface{}), a.Error(1) } -func (m *mockDB) Close() error { +func (m *mockDB) CloseDB() error { a := m.Called() return a.Error(0) }