diff options
author | Bin Yang <bin.yang@windriver.com> | 2019-03-26 09:01:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-26 09:01:17 +0000 |
commit | 25682fe21ea85e807490229c2e8c8fd6a5963d25 (patch) | |
tree | 1b4e982f05af3db0c2c1f87cc2f0456a7eb1605f /src/k8splugin/internal/db/store.go | |
parent | 967ff89e7dd42a374e5313447e92489bf27ac2d0 (diff) | |
parent | 037cfda2181e4995e4e2a47db6f1121b532b686b (diff) |
Merge "Add support for composite keys"
Diffstat (limited to 'src/k8splugin/internal/db/store.go')
-rw-r--r-- | src/k8splugin/internal/db/store.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/k8splugin/internal/db/store.go b/src/k8splugin/internal/db/store.go index a235597a..148e078e 100644 --- a/src/k8splugin/internal/db/store.go +++ b/src/k8splugin/internal/db/store.go @@ -23,6 +23,13 @@ import ( // DBconn interface used to talk a concrete Database connection var DBconn Store +// Key is an interface that will be implemented by anypackage +// that wants to use the Store interface. This allows various +// db backends and key types. +type Key interface { + String() string +} + // Store is an interface for accessing a database type Store interface { // Returns nil if db health is good @@ -33,19 +40,19 @@ type Store interface { // Creates a new master table with key and links data with tag and // creates a pointer to the newly added data in the master table - Create(table, key, tag string, data interface{}) error + Create(table string, key Key, tag string, data interface{}) error // Reads data for a particular key with specific tag. - Read(table, key, tag string) ([]byte, error) + Read(table string, key Key, tag string) ([]byte, error) //TODO: Update(context.Context, string, interface{}) error // Deletes a specific tag data for key. // TODO: If tag is empty, it will delete all tags under key. - Delete(table, key, tag string) error + Delete(table string, key Key, tag string) error // Reads all master tables and data from the specified tag in table - ReadAll(table, tag string) (map[string][]byte, error) + ReadAll(table string, tag string) (map[string][]byte, error) } // CreateDBClient creates the DB client |