diff options
author | Victor Morales <victor.morales@intel.com> | 2018-12-15 00:34:27 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-12-15 00:34:27 +0000 |
commit | 2da9b6c0498528a6eac478fa7b334906457f7b82 (patch) | |
tree | be33f0fadf12c321c9a20eaf943eda5b43335948 /src/k8splugin/db/store.go | |
parent | b878686931d404568af000df1f0f86927a730680 (diff) | |
parent | d203ccf9174e450b6f5a6a9aabea95b73c9973ff (diff) |
Merge "Migrating from consul to mongodb for backend"
Diffstat (limited to 'src/k8splugin/db/store.go')
-rw-r--r-- | src/k8splugin/db/store.go | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/k8splugin/db/store.go b/src/k8splugin/db/store.go index c1a8b31f..a235597a 100644 --- a/src/k8splugin/db/store.go +++ b/src/k8splugin/db/store.go @@ -25,21 +25,38 @@ var DBconn Store // Store is an interface for accessing a database type Store interface { + // Returns nil if db health is good HealthCheck() error - Create(string, string) error - Read(string) (string, error) - // Update(string) (string, error) - Delete(string) error + // Unmarshal implements any unmarshaling needed for the database + Unmarshal(inp []byte, out interface{}) error - ReadAll(string) ([]string, error) + // 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 + + // Reads data for a particular key with specific tag. + Read(table, 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 + + // Reads all master tables and data from the specified tag in table + ReadAll(table, tag string) (map[string][]byte, error) } // CreateDBClient creates the DB client func CreateDBClient(dbType string) error { var err error switch dbType { + case "mongo": + // create a mongodb database with k8splugin as the name + DBconn, err = NewMongoStore("k8splugin", nil) case "consul": + // create a consul kv store DBconn, err = NewConsulStore(nil) default: return pkgerrors.New(dbType + "DB not supported") |