db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Connection types
	BADGER    string = "badger"
	COCKROACH string = "cockroach"
	TESTSTORE string = "teststore"
	UNDEFINED string = "undefined"
)

db-wide constants

View Source
const (
	TestCreatedTime = "2006-01-02T15:04:05Z"
	TestUpdatedTime = "2006-01-08T10:00:08Z"
	TestKey         = "a key"
	TestVal         = "a value"
)

Constants for testing

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerConnector

type BadgerConnector struct {
	ConnType string
	Conn     *badger.DB
}

BadgerConnector ...

func NewBadgerConnector

func NewBadgerConnector(cfg *config.Config) (*BadgerConnector, error)

NewBadgerConnector ...

func (*BadgerConnector) Close

func (c *BadgerConnector) Close() error

Close closes the connection to the database

func (*BadgerConnector) DBType

func (c *BadgerConnector) DBType() string

DBType returns the database type

func (*BadgerConnector) Get

func (c *BadgerConnector) Get(key string) (*KV, error)

Get ...

func (*BadgerConnector) Set

func (c *BadgerConnector) Set(input *KV) error

Set ...

type CockroachConnector

type CockroachConnector struct {
	ConnType string
}

CockroachConnector ...

func NewCockroachConnector

func NewCockroachConnector(_ *config.Config) (*CockroachConnector, error)

NewCockroachConnector ...

func (*CockroachConnector) Close

func (c *CockroachConnector) Close() error

Close closes the connection to the database

func (*CockroachConnector) DBType

func (c *CockroachConnector) DBType() string

DBType returns the database type

func (*CockroachConnector) Get

func (c *CockroachConnector) Get(key string) (*KV, error)

Get ...

func (*CockroachConnector) Set

func (c *CockroachConnector) Set(inpuc *KV) error

Set ...

type DB

type DB interface {
	Close() error
	DBType() string
	Get(key string) (*KV, error)
	Set(*KV) error
}

DB ...

func Open

func Open(cfg *config.Config) (DB, error)

Open dispatches the creation of a specific DB connection type

type KV

type KV struct {
	Key     string
	Value   []byte
	Created *time.Time
	Updated *time.Time
}

KV ...

type TestStoreConnector

type TestStoreConnector struct {
	ConnType string
}

TestStoreConnector is for test dbs that will be used in unit tests

func NewTestStoreConnector

func NewTestStoreConnector(_ *config.Config) (*TestStoreConnector, error)

NewTestStoreConnector is for use with unit tests

func (*TestStoreConnector) Close

func (c *TestStoreConnector) Close() error

Close closes the connection to the database

func (*TestStoreConnector) DBType

func (c *TestStoreConnector) DBType() string

DBType returns the database type

func (*TestStoreConnector) Get

func (c *TestStoreConnector) Get(key string) (*KV, error)

Get ...

func (*TestStoreConnector) Set

func (c *TestStoreConnector) Set(inpuc *KV) error

Set ...

type UndefinedConnector

type UndefinedConnector struct {
	ConnType string
}

UndefinedConnector is for situations where an implementation needs to be returned, even when there is none.

func NewUndefinedConnection

func NewUndefinedConnection(err error) (*UndefinedConnector, error)

NewUndefinedConnection is for use with unit tests

func (*UndefinedConnector) Close

func (c *UndefinedConnector) Close() error

Close closes the connection to the database

func (*UndefinedConnector) DBType

func (c *UndefinedConnector) DBType() string

DBType returns the database type

func (*UndefinedConnector) Get

func (c *UndefinedConnector) Get(key string) (*KV, error)

Get ...

func (*UndefinedConnector) Set

func (c *UndefinedConnector) Set(inpuc *KV) error

Set ...

Jump to

Keyboard shortcuts

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