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
- func GetStore(configMap map[string]interface{}) (common.Store, error)
- type DbStore
- func (dbStore *DbStore) Connect() error
- func (dbStore *DbStore) CreateSchema(force bool) error
- func (dbStore *DbStore) DbStore() DbStore
- func (dbStore *DbStore) Find(query url.Values, entities interface{}, flag common.FindFlag) (interface{}, error)
- func (dbStore *DbStore) GetPasswordFunction() (string, error)
- func (dbStore *DbStore) SetConfig(config common.StoreConfig) error
- type KvStore
- func (kvStore *KvStore) AddHost(dc common.Datacenter, host *common.Host) error
- func (kvStore *KvStore) Connect() error
- func (kvStore *KvStore) CreateSchema(force bool) error
- func (kvStore *KvStore) DeleteHost(hostID uint64) error
- func (kvStore *KvStore) Find(query url.Values, entities interface{}, flag common.FindFlag) (interface{}, error)
- func (kvStore KvStore) GetHost(hostID uint64) (common.Host, error)
- func (kvStore *KvStore) ListHosts() ([]common.Host, error)
- func (kvStore *KvStore) SetConfig(config common.StoreConfig) error
- type PolicyDb
- type RdbmsStore
- func (rdbms *RdbmsStore) AddHost(dc common.Datacenter, host *common.Host) error
- func (rdbms *RdbmsStore) CreateSchemaPostProcess() error
- func (rdbms *RdbmsStore) DeleteHost(hostID uint64) error
- func (rdbms *RdbmsStore) Entities() []interface{}
- func (rdbms *RdbmsStore) GetHost(hostID uint64) (common.Host, error)
- func (rdbms *RdbmsStore) ListHosts() ([]common.Host, error)
- type RomanaLibkvStore
Constants ¶
const (
BITS_IN_BYTE uint = 8
)
const (
DefaultConnectionTimeout = 10 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
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 ¶
Connect connects to the appropriate DB (mutating dbStore's state with the connection information), or returns an error.
func (*DbStore) CreateSchema ¶
CreateSchema creates the schema in this DB. If force flag is specified, the schema is dropped and recreated.
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 ¶
GetPasswordFunction returns appropriate function to hash password depending on the underlying DB (note that in sqlite it is plain text).
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 ¶
AddHost adds the host. If RomanaIp is not specified for it, a new RomanaIp is generated and assigned to it.
func (*KvStore) Connect ¶
Connect connects to the appropriate DB (mutating dbStore's state with the connection information), or returns an error.
func (*KvStore) CreateSchema ¶
CreateSchema creates the schema in this DB. If force flag is specified, the schema is dropped and recreated.
func (*KvStore) DeleteHost ¶
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.
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
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()
type RomanaLibkvStore ¶
type RomanaLibkvStore struct { // Prefix for keys Prefix string libkvStore.Store }
RomanaLibkvStore enhances libkv.store.Store with some operations useful for Romana