From 3b33634b343085149e2c1dd95f7fd8b86777d04c Mon Sep 17 00:00:00 2001 From: Boris Glimcher Date: Thu, 29 Feb 2024 20:34:33 +0200 Subject: [PATCH] Add GetClient method to all implementations this will allow users to amend few settings after c-tor Fixes #184 Signed-off-by: Boris Glimcher --- badgerdb/badgerdb.go | 5 +++++ bbolt/bbolt.go | 5 +++++ bigcache/bigcache.go | 5 +++++ consul/consul.go | 5 +++++ datastore/datastore.go | 5 +++++ docs.go | 2 +- dynamodb/dynamodb.go | 5 +++++ etcd/etcd.go | 5 +++++ freecache/freecache.go | 5 +++++ gomap/gomap.go | 5 +++++ hazelcast/hazelcast.go | 5 +++++ ignite/ignite.go | 5 +++++ leveldb/leveldb.go | 5 +++++ memcached/memcached.go | 5 +++++ mongodb/mongodb.go | 5 +++++ mysql/mysql.go | 5 +++++ redis/redis.go | 5 +++++ s3/s3.go | 5 +++++ sql/sql.go | 5 +++++ syncmap/syncmap.go | 5 +++++ tablestorage/tablestorage.go | 5 +++++ tablestore/tablestore.go | 5 +++++ zookeeper/zookeeper.go | 5 +++++ 23 files changed, 111 insertions(+), 1 deletion(-) diff --git a/badgerdb/badgerdb.go b/badgerdb/badgerdb.go index 9715972f..df3b7f4e 100644 --- a/badgerdb/badgerdb.go +++ b/badgerdb/badgerdb.go @@ -13,6 +13,11 @@ type Store struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (s Store) GetStore() *badger.DB { + return s.db +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/bbolt/bbolt.go b/bbolt/bbolt.go index 3a50c8c0..e40b3663 100644 --- a/bbolt/bbolt.go +++ b/bbolt/bbolt.go @@ -14,6 +14,11 @@ type Store struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (s Store) GetStore() *bolt.DB { + return s.db +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/bigcache/bigcache.go b/bigcache/bigcache.go index 7f9653a2..4a61422c 100644 --- a/bigcache/bigcache.go +++ b/bigcache/bigcache.go @@ -16,6 +16,11 @@ type Store struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (s Store) GetStore() *bigcache.BigCache { + return s.s +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/consul/consul.go b/consul/consul.go index d99de5c4..f1711f59 100644 --- a/consul/consul.go +++ b/consul/consul.go @@ -14,6 +14,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *api.KV { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/datastore/datastore.go b/datastore/datastore.go index 5c736ce3..8d21cf60 100644 --- a/datastore/datastore.go +++ b/datastore/datastore.go @@ -31,6 +31,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *datastore.Client { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/docs.go b/docs.go index a859b2c7..3054c540 100644 --- a/docs.go +++ b/docs.go @@ -2,7 +2,7 @@ Package gokv contains a simple key-value store abstraction in the form of a Go interface. Implementations of the gokv.Store interface can be found in the sub-packages. -Usage +# Usage Example code for using Redis: diff --git a/dynamodb/dynamodb.go b/dynamodb/dynamodb.go index b4e87366..e78af505 100644 --- a/dynamodb/dynamodb.go +++ b/dynamodb/dynamodb.go @@ -28,6 +28,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *awsdynamodb.DynamoDB { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/etcd/etcd.go b/etcd/etcd.go index 370d117f..6022ce6f 100644 --- a/etcd/etcd.go +++ b/etcd/etcd.go @@ -21,6 +21,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *clientv3.Client { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/freecache/freecache.go b/freecache/freecache.go index 05a9bd65..cd5ed1f1 100644 --- a/freecache/freecache.go +++ b/freecache/freecache.go @@ -15,6 +15,11 @@ type Store struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (s Store) GetStore() *freecache.Cache { + return s.s +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/gomap/gomap.go b/gomap/gomap.go index 3fb78f85..4477889c 100644 --- a/gomap/gomap.go +++ b/gomap/gomap.go @@ -14,6 +14,11 @@ type Store struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (s Store) GetStore() map[string][]byte { + return s.m +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/hazelcast/hazelcast.go b/hazelcast/hazelcast.go index 2cdbe14b..8259e629 100644 --- a/hazelcast/hazelcast.go +++ b/hazelcast/hazelcast.go @@ -19,6 +19,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *hazelcast.Client { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/ignite/ignite.go b/ignite/ignite.go index c56772d5..575eedfc 100644 --- a/ignite/ignite.go +++ b/ignite/ignite.go @@ -18,6 +18,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() ignite.Client { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/leveldb/leveldb.go b/leveldb/leveldb.go index 588c477d..1820ac62 100644 --- a/leveldb/leveldb.go +++ b/leveldb/leveldb.go @@ -15,6 +15,11 @@ type Store struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (s Store) GetStore() *leveldb.DB { + return s.db +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/memcached/memcached.go b/memcached/memcached.go index 86ec03b8..2408667d 100644 --- a/memcached/memcached.go +++ b/memcached/memcached.go @@ -17,6 +17,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *memcache.Client { + return c.c +} + // Set stores the given value for the given key. // The key must not be longer than 250 bytes (this is a restriction of Memcached). // Values are automatically marshalled to JSON or gob (depending on the configuration). diff --git a/mongodb/mongodb.go b/mongodb/mongodb.go index c3dfe796..ac6a1539 100644 --- a/mongodb/mongodb.go +++ b/mongodb/mongodb.go @@ -55,6 +55,11 @@ type Client struct { cancel context.CancelFunc } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *mongo.Collection { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/mysql/mysql.go b/mysql/mysql.go index babdb327..b51aca11 100644 --- a/mysql/mysql.go +++ b/mysql/mysql.go @@ -24,6 +24,11 @@ type Client struct { c *sql.Client } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *sql.Client { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The length of the key must not exceed 255 characters. diff --git a/redis/redis.go b/redis/redis.go index 5ec6ad63..5dc86899 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -19,6 +19,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *redis.Client { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/s3/s3.go b/s3/s3.go index b0478f77..a5528941 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -22,6 +22,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *awss3.S3 { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/sql/sql.go b/sql/sql.go index bee440eb..6bfd2534 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -16,6 +16,11 @@ type Client struct { Codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *sql.DB { + return c.C +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/syncmap/syncmap.go b/syncmap/syncmap.go index a366455b..3d0d6c51 100644 --- a/syncmap/syncmap.go +++ b/syncmap/syncmap.go @@ -13,6 +13,11 @@ type Store struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (s Store) GetStore() *sync.Map { + return s.m +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/tablestorage/tablestorage.go b/tablestorage/tablestorage.go index 81956025..a46a7b29 100644 --- a/tablestorage/tablestorage.go +++ b/tablestorage/tablestorage.go @@ -30,6 +30,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *storage.Table { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/tablestore/tablestore.go b/tablestore/tablestore.go index 7925a36b..0197d34c 100644 --- a/tablestore/tablestore.go +++ b/tablestore/tablestore.go @@ -20,6 +20,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *tablestore.TableStoreClient { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil. diff --git a/zookeeper/zookeeper.go b/zookeeper/zookeeper.go index b41e4ee8..88dc1c5a 100644 --- a/zookeeper/zookeeper.go +++ b/zookeeper/zookeeper.go @@ -18,6 +18,11 @@ type Client struct { codec encoding.Codec } +// Gets underlying store to allow user manipulate object directly. +func (c Client) GetStore() *zk.Conn { + return c.c +} + // Set stores the given value for the given key. // Values are automatically marshalled to JSON or gob (depending on the configuration). // The key must not be "" and the value must not be nil.