Skip to content

Commit cdf3549

Browse files
committed
Add GetClient method to all implementations
this will allow users to amend few settings after c-tor Fixes philippgille#184 Signed-off-by: Boris Glimcher <[email protected]>
1 parent 0a05f2e commit cdf3549

File tree

23 files changed

+111
-1
lines changed

23 files changed

+111
-1
lines changed

badgerdb/badgerdb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ type Store struct {
1313
codec encoding.Codec
1414
}
1515

16+
// Gets underlying store to allow user manipulate object directly.
17+
func (s Store) GetStore() *badger.DB {
18+
return s.db
19+
}
20+
1621
// Set stores the given value for the given key.
1722
// Values are automatically marshalled to JSON or gob (depending on the configuration).
1823
// The key must not be "" and the value must not be nil.

bbolt/bbolt.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ type Store struct {
1414
codec encoding.Codec
1515
}
1616

17+
// Gets underlying store to allow user manipulate object directly.
18+
func (s Store) GetStore() *bolt.DB {
19+
return s.db
20+
}
21+
1722
// Set stores the given value for the given key.
1823
// Values are automatically marshalled to JSON or gob (depending on the configuration).
1924
// The key must not be "" and the value must not be nil.

bigcache/bigcache.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ type Store struct {
1616
codec encoding.Codec
1717
}
1818

19+
// Gets underlying store to allow user manipulate object directly.
20+
func (s Store) GetStore() *bigcache.BigCache {
21+
return s.s
22+
}
23+
1924
// Set stores the given value for the given key.
2025
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2126
// The key must not be "" and the value must not be nil.

consul/consul.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ type Client struct {
1414
codec encoding.Codec
1515
}
1616

17+
// Gets underlying store to allow user manipulate object directly.
18+
func (c Client) GetStore() *api.KV {
19+
return c.c
20+
}
21+
1722
// Set stores the given value for the given key.
1823
// Values are automatically marshalled to JSON or gob (depending on the configuration).
1924
// The key must not be "" and the value must not be nil.

datastore/datastore.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ type Client struct {
3131
codec encoding.Codec
3232
}
3333

34+
// Gets underlying store to allow user manipulate object directly.
35+
func (c Client) GetStore() *datastore.Client {
36+
return c.c
37+
}
38+
3439
// Set stores the given value for the given key.
3540
// Values are automatically marshalled to JSON or gob (depending on the configuration).
3641
// The key must not be "" and the value must not be nil.

docs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Package gokv contains a simple key-value store abstraction in the form of a Go interface.
33
Implementations of the gokv.Store interface can be found in the sub-packages.
44
5-
Usage
5+
# Usage
66
77
Example code for using Redis:
88

dynamodb/dynamodb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ type Client struct {
2828
codec encoding.Codec
2929
}
3030

31+
// Gets underlying store to allow user manipulate object directly.
32+
func (c Client) GetStore() *awsdynamodb.DynamoDB {
33+
return c.c
34+
}
35+
3136
// Set stores the given value for the given key.
3237
// Values are automatically marshalled to JSON or gob (depending on the configuration).
3338
// The key must not be "" and the value must not be nil.

etcd/etcd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ type Client struct {
2121
codec encoding.Codec
2222
}
2323

24+
// Gets underlying store to allow user manipulate object directly.
25+
func (c Client) GetStore() *clientv3.Client {
26+
return c.c
27+
}
28+
2429
// Set stores the given value for the given key.
2530
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2631
// The key must not be "" and the value must not be nil.

freecache/freecache.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ type Store struct {
1515
codec encoding.Codec
1616
}
1717

18+
// Gets underlying store to allow user manipulate object directly.
19+
func (s Store) GetStore() *freecache.Cache {
20+
return s.s
21+
}
22+
1823
// Set stores the given value for the given key.
1924
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2025
// The key must not be "" and the value must not be nil.

gomap/gomap.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ type Store struct {
1414
codec encoding.Codec
1515
}
1616

17+
// Gets underlying store to allow user manipulate object directly.
18+
func (s Store) GetStore() map[string][]byte {
19+
return s.m
20+
}
21+
1722
// Set stores the given value for the given key.
1823
// Values are automatically marshalled to JSON or gob (depending on the configuration).
1924
// The key must not be "" and the value must not be nil.

hazelcast/hazelcast.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ type Client struct {
1919
codec encoding.Codec
2020
}
2121

22+
// Gets underlying store to allow user manipulate object directly.
23+
func (c Client) GetStore() *hazelcast.Client {
24+
return c.c
25+
}
26+
2227
// Set stores the given value for the given key.
2328
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2429
// The key must not be "" and the value must not be nil.

ignite/ignite.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ type Client struct {
1818
codec encoding.Codec
1919
}
2020

21+
// Gets underlying store to allow user manipulate object directly.
22+
func (c Client) GetStore() *ignite.Client {
23+
return c.c
24+
}
25+
2126
// Set stores the given value for the given key.
2227
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2328
// The key must not be "" and the value must not be nil.

leveldb/leveldb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ type Store struct {
1515
codec encoding.Codec
1616
}
1717

18+
// Gets underlying store to allow user manipulate object directly.
19+
func (s Store) GetStore() *leveldb.DB {
20+
return s.db
21+
}
22+
1823
// Set stores the given value for the given key.
1924
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2025
// The key must not be "" and the value must not be nil.

memcached/memcached.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ type Client struct {
1717
codec encoding.Codec
1818
}
1919

20+
// Gets underlying store to allow user manipulate object directly.
21+
func (c Client) GetStore() *memcache.Client {
22+
return c.c
23+
}
24+
2025
// Set stores the given value for the given key.
2126
// The key must not be longer than 250 bytes (this is a restriction of Memcached).
2227
// Values are automatically marshalled to JSON or gob (depending on the configuration).

mongodb/mongodb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ type Client struct {
5555
cancel context.CancelFunc
5656
}
5757

58+
// Gets underlying store to allow user manipulate object directly.
59+
func (c Client) GetStore() *mongo.Collection {
60+
return c.c
61+
}
62+
5863
// Set stores the given value for the given key.
5964
// Values are automatically marshalled to JSON or gob (depending on the configuration).
6065
// The key must not be "" and the value must not be nil.

mysql/mysql.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ type Client struct {
2424
c *sql.Client
2525
}
2626

27+
// Gets underlying store to allow user manipulate object directly.
28+
func (c Client) GetStore() *sql.Client {
29+
return c.c
30+
}
31+
2732
// Set stores the given value for the given key.
2833
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2934
// The length of the key must not exceed 255 characters.

redis/redis.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ type Client struct {
1919
codec encoding.Codec
2020
}
2121

22+
// Gets underlying store to allow user manipulate object directly.
23+
func (c Client) GetStore() *redis.Client {
24+
return c.c
25+
}
26+
2227
// Set stores the given value for the given key.
2328
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2429
// The key must not be "" and the value must not be nil.

s3/s3.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ type Client struct {
2222
codec encoding.Codec
2323
}
2424

25+
// Gets underlying store to allow user manipulate object directly.
26+
func (c Client) GetStore() *awss3.S3 {
27+
return c.c
28+
}
29+
2530
// Set stores the given value for the given key.
2631
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2732
// The key must not be "" and the value must not be nil.

sql/sql.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ type Client struct {
1616
Codec encoding.Codec
1717
}
1818

19+
// Gets underlying store to allow user manipulate object directly.
20+
func (c Client) GetStore() *sql.DB {
21+
return c.C
22+
}
23+
1924
// Set stores the given value for the given key.
2025
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2126
// The key must not be "" and the value must not be nil.

syncmap/syncmap.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ type Store struct {
1313
codec encoding.Codec
1414
}
1515

16+
// Gets underlying store to allow user manipulate object directly.
17+
func (s Store) GetStore() *sync.Map {
18+
return s.m
19+
}
20+
1621
// Set stores the given value for the given key.
1722
// Values are automatically marshalled to JSON or gob (depending on the configuration).
1823
// The key must not be "" and the value must not be nil.

tablestorage/tablestorage.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ type Client struct {
3030
codec encoding.Codec
3131
}
3232

33+
// Gets underlying store to allow user manipulate object directly.
34+
func (c Client) GetStore() *storage.Table {
35+
return c.c
36+
}
37+
3338
// Set stores the given value for the given key.
3439
// Values are automatically marshalled to JSON or gob (depending on the configuration).
3540
// The key must not be "" and the value must not be nil.

tablestore/tablestore.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ type Client struct {
2020
codec encoding.Codec
2121
}
2222

23+
// Gets underlying store to allow user manipulate object directly.
24+
func (c Client) GetStore() *tablestore.TableStoreClient {
25+
return c.c
26+
}
27+
2328
// Set stores the given value for the given key.
2429
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2530
// The key must not be "" and the value must not be nil.

zookeeper/zookeeper.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ type Client struct {
1818
codec encoding.Codec
1919
}
2020

21+
// Gets underlying store to allow user manipulate object directly.
22+
func (c Client) GetStore() *zk.Conn {
23+
return c.c
24+
}
25+
2126
// Set stores the given value for the given key.
2227
// Values are automatically marshalled to JSON or gob (depending on the configuration).
2328
// The key must not be "" and the value must not be nil.

0 commit comments

Comments
 (0)