database

package
v0.0.0-...-3fd5aad Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedDriver

type BufferedDriver interface {
	Driver
	Bytes() ([]byte, error)
}

BufferedDriver represents a low level storage which exposes a Bytes method to allow serialization to disk

func NewMemoryDBDriverWithCollection

func NewMemoryDBDriverWithCollection(collection []map[string]string) (BufferedDriver, error)

NewMemoryDBDriverWithCollection seeds the memory database with some initialisaiton data

type DBTableRecordType

type DBTableRecordType string

func (DBTableRecordType) String

func (dbtype DBTableRecordType) String() string

type Database

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

Database stores data for terraform server

func NewDatabaseWithDriver

func NewDatabaseWithDriver(driver Driver) Database

NewDatabaseWithDriver creates a new Database struct with

func (*Database) Close

func (db *Database) Close() error

func (*Database) Create

func (db *Database) Create(recordType DBTableRecordType, key string, doc interface{}) error

func (*Database) Delete

func (db *Database) Delete(recordType DBTableRecordType, key string) error

func (*Database) List

func (db *Database) List(recordType DBTableRecordType, i interface{}) (err error)

func (*Database) Ping

func (db *Database) Ping() error

func (*Database) Read

func (db *Database) Read(recordType DBTableRecordType, key string, i interface{}) error

func (*Database) Update

func (db *Database) Update(recordType DBTableRecordType, key string, doc interface{}) error

type Driver

type Driver interface {
	Create(recordType DBTableRecordType, key string, doc interface{}) error
	Read(recordType DBTableRecordType, key string, i interface{}) error
	List(recordType DBTableRecordType, i interface{}) error
	Update(recordType DBTableRecordType, key string, doc interface{}) error
	Delete(recordType DBTableRecordType, key string) error

	Ping() error
	Close() error
}

Driver represents a low level storage serialiser/ deserialiser This is wrapped in the Database

func NewJSONDBDriver

func NewJSONDBDriver(dbFile string) (d Driver, err error)

NewJSONDBDriver returns a json database object

func NewMemoryDBDriver

func NewMemoryDBDriver() (Driver, error)

NewMemoryDBDriver returns a memory database object

func NewRedisDBDriver

func NewRedisDBDriver(namespace, address, password string, database int, driver RedisClient) (r Driver, err error)

NewRedisDBDriver returns a redis database object

type Record

type Record struct {
	Key   string
	Type  DBTableRecordType
	Value string
}

Record is an untyped, schemaless record type which all record types embed and implement

type RecordDoesNotExistError

type RecordDoesNotExistError error

type RecordExistsError

type RecordExistsError error

type RedisClient

type RedisClient interface {
	Close() error
	Del(...string) *redis.IntCmd
	Keys(string) *redis.StringSliceCmd
	Get(string) *redis.StringCmd
	MGet(keys ...string) *redis.SliceCmd
	Ping() *redis.StatusCmd
	Set(string, interface{}, time.Duration) *redis.StatusCmd
}

RedisClient interface to allow custom redis clients to be used

Jump to

Keyboard shortcuts

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