summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/db/store.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/k8splugin/internal/db/store.go')
-rw-r--r--src/k8splugin/internal/db/store.go15
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