store

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package store provides routines for backing storage, currently supporting libkv and RDBMS-based backends.

Package store provides a flexible key value backend to be used with Romana services based of on docker/libkv.

Index

Constants

View Source
const (
	BITS_IN_BYTE uint = 8
)
View Source
const (
	DefaultConnectionTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func GetStore

func GetStore(configMap map[string]interface{}) (common.Store, error)

GetStore is a factory method, returning the appropriate store provided the config.

Types

type DbStore

type DbStore struct {
	common.ServiceStore
	Config *common.StoreConfig
	Db     *gorm.DB
	// contains filtered or unexported fields
}

DbStore is a to-be-deprecated structure storing information specific to RDBMS-based implementation of Store.

func (*DbStore) Connect

func (dbStore *DbStore) Connect() error

Connect connects to the appropriate DB (mutating dbStore's state with the connection information), or returns an error.

func (*DbStore) CreateSchema

func (dbStore *DbStore) CreateSchema(force bool) error

CreateSchema creates the schema in this DB. If force flag is specified, the schema is dropped and recreated.

func (*DbStore) DbStore

func (dbStore *DbStore) DbStore() DbStore

func (*DbStore) Find

func (dbStore *DbStore) Find(query url.Values, entities interface{}, flag common.FindFlag) (interface{}, error)

Find generically implements Find() of Store interface for DbStore

func (*DbStore) GetPasswordFunction

func (dbStore *DbStore) GetPasswordFunction() (string, error)

GetPasswordFunction returns appropriate function to hash password depending on the underlying DB (note that in sqlite it is plain text).

func (*DbStore) SetConfig

func (dbStore *DbStore) SetConfig(config common.StoreConfig) error

SetConfig sets the config object from a map.

type KvStore

type KvStore struct {
	Config *common.StoreConfig
	Db     RomanaLibkvStore
}

KvStore is a structure storing information specific to KV-based implementation of Store.

func (*KvStore) AddHost

func (kvStore *KvStore) AddHost(dc common.Datacenter, host *common.Host) error

AddHost adds the host. If RomanaIp is not specified for it, a new RomanaIp is generated and assigned to it.

func (*KvStore) Connect

func (kvStore *KvStore) Connect() error

Connect connects to the appropriate DB (mutating dbStore's state with the connection information), or returns an error.

func (*KvStore) CreateSchema

func (kvStore *KvStore) CreateSchema(force bool) error

CreateSchema creates the schema in this DB. If force flag is specified, the schema is dropped and recreated.

func (*KvStore) DeleteHost

func (kvStore *KvStore) DeleteHost(hostID uint64) error

DeleteHost deletes host based on supplied ID.

func (*KvStore) Find

func (kvStore *KvStore) Find(query url.Values, entities interface{}, flag common.FindFlag) (interface{}, error)

Find generically implements Find() of Store interface for KvStore.

func (KvStore) GetHost

func (kvStore KvStore) GetHost(hostID uint64) (common.Host, error)

GetHost gets the host information based on provided ID.

func (*KvStore) ListHosts

func (kvStore *KvStore) ListHosts() ([]common.Host, error)

ListHosts lists available hosts.

func (*KvStore) SetConfig

func (kvStore *KvStore) SetConfig(config common.StoreConfig) error

SetConfig sets the config object from a map.

type PolicyDb

type PolicyDb struct {
	ID uint64 `sql:"AUTO_INCREMENT"`
	// Policy document as JSON
	Policy       string         `sql:"type:TEXT"`
	ExternalID   sql.NullString `json:"external_id,omitempty" sql:"unique"`
	DatacenterID string
	// DeletedAt is for using soft delete functionality
	// from http://jinzhu.me/gorm/curd.html#delete
	DeletedAt *time.Time
}

policyDb represents how common.Policy is stored in the database. For now to keep it simple, it will not be fully normalized -- we will just keep an ID and policy document as JSON

func (PolicyDb) TableName

func (PolicyDb) TableName() string

Name specifies a nicer-looking table name.

type RdbmsStore

type RdbmsStore struct {
	common.ServiceStore
	DbStore
}

RdbmsStore is to be a full implementation of DbStore including implementing ServiceStore interface. Eventually to lead to collapse of DbStore and RdbmsStore into one and removal of ServiceStore interface, having one single store for all services.

func (*RdbmsStore) AddHost

func (rdbms *RdbmsStore) AddHost(dc common.Datacenter, host *common.Host) error

AddHost adds a new host. It also makes sure that if a Romana CIDR is not assigned, then to create and assign a new romana cidr using help of helper functions like findFirstAvaiableID and getNetworkFromID.

func (*RdbmsStore) CreateSchemaPostProcess

func (rdbms *RdbmsStore) CreateSchemaPostProcess() error

func (*RdbmsStore) DeleteHost

func (rdbms *RdbmsStore) DeleteHost(hostID uint64) error

DeleteHost is currently not implemented.

func (*RdbmsStore) Entities

func (rdbms *RdbmsStore) Entities() []interface{}

Entities is to implement ServiceStore.Entities()

func (*RdbmsStore) GetHost

func (rdbms *RdbmsStore) GetHost(hostID uint64) (common.Host, error)

FindHost implements FindHost method of Store interface

func (*RdbmsStore) ListHosts

func (rdbms *RdbmsStore) ListHosts() ([]common.Host, error)

ListHosts implements ListHosts method of Store interface

type RomanaLibkvStore

type RomanaLibkvStore struct {
	// Prefix for keys
	Prefix string
	libkvStore.Store
}

RomanaLibkvStore enhances libkv.store.Store with some operations useful for Romana

Jump to

Keyboard shortcuts

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