db

package
v0.0.0-...-d82845d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateDBClient = func(dbType string) error {
	if dbType == "consul" {
		DBconn = &ConsulDB{}
		return nil
	}

	return pkgerrors.New("No suitable DB found")
}

CreateDBClient creates the DB client

Functions

This section is empty.

Types

type ConsulDB

type ConsulDB struct {
	// contains filtered or unexported fields
}

ConsulDB is an implementation of the DatabaseConnection interface

func (*ConsulDB) CheckDatabase

func (c *ConsulDB) CheckDatabase() error

CheckDatabase checks if the database is running

func (*ConsulDB) CreateEntry

func (c *ConsulDB) CreateEntry(key string, value string) error

CreateEntry is used to create a DB entry

func (*ConsulDB) DeleteEntry

func (c *ConsulDB) DeleteEntry(key string) error

DeleteEntry is used to delete an ID

func (*ConsulDB) InitializeDatabase

func (c *ConsulDB) InitializeDatabase() error

InitializeDatabase initialized the initial steps

func (*ConsulDB) ReadAll

func (c *ConsulDB) ReadAll(prefix string) ([]string, error)

ReadAll is used to get all ExternalIDs in a namespace

func (*ConsulDB) ReadEntry

func (c *ConsulDB) ReadEntry(key string) (string, bool, error)

ReadEntry returns the internalID for a particular externalID is present in a namespace

type DatabaseConnection

type DatabaseConnection interface {
	InitializeDatabase() error
	CheckDatabase() error
	CreateEntry(string, string) error
	ReadEntry(string) (string, bool, error)
	DeleteEntry(string) error
	ReadAll(string) ([]string, error)
}

DatabaseConnection is an interface for accessing a database

var DBconn DatabaseConnection

DBconn interface used to talk a concrete Database connection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL