Documentation ¶
Index ¶
- Constants
- type Commitlog
- func (c *Commitlog) Add(key string, status uint16, rev uint32, bs *util.ByteStream) error
- func (c *Commitlog) Get(key string) *util.ByteStream
- func (c *Commitlog) GetByHash(hKey uint32) *util.ByteStream
- func (c *Commitlog) GetSummary() index.Summary
- func (c *Commitlog) Keys() []string
- func (c *Commitlog) LoadData()
- func (c *Commitlog) RenameTo(newpath string)
- func (c *Commitlog) Size() (int64, error)
- type DBManager
- func (dbm *DBManager) CreateDatabase(descriptor DatabaseDescriptor) error
- func (dbm *DBManager) DropDatabase(dbname string) error
- func (dbm *DBManager) GetData(dbname string, strKey string) <-chan *model.DataDefinition
- func (dbm *DBManager) GetDatabase(dbname string) (*Database, bool)
- func (dbm *DBManager) GetDatabasesNames() []string
- func (dbm *DBManager) LoadDatabases()
- func (dbm *DBManager) Start()
- func (dbm *DBManager) Stop()
- type DataHolder
- type Database
- func (db *Database) Close()
- func (db *Database) GetDataByIndexEntry(dhIdx int, entry *index.Entry) (*model.DataDefinition, bool)
- func (db *Database) GetDataByKey(key string) (*model.DataDefinition, bool)
- func (db *Database) GetDataIndexByKey(hkey uint32) (*index.Entry, int, bool)
- func (db *Database) Info() DatabaseInfo
- func (db *Database) InsertCheckUpsert(df *model.DataDefinition, upsert bool) (uint32, error)
- func (db *Database) InsertData(df *model.DataDefinition) error
- func (db *Database) Keys() []string
- func (db *Database) LoadData()
- type DatabaseConfig
- type DatabaseDescriptor
- type DatabaseInfo
- type SparrowConfig
- type XMLDatabaseList
Constants ¶
const (
// DefaultDatabaseConfigFile databases definition
DefaultDatabaseConfigFile = "database.xml"
)
const (
// DefaultSparrowConfigFile is the default configuration file
DefaultSparrowConfigFile = "sparrow.xml"
)
const (
// FolderCommitlog keeps default commitlog folder name
FolderCommitlog = "commitlog"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commitlog ¶
type Commitlog struct {
// contains filtered or unexported fields
}
Commitlog holds commitlog information
func (*Commitlog) Get ¶
func (c *Commitlog) Get(key string) *util.ByteStream
Get returns ByteStream with requested data, nil if not found
func (*Commitlog) GetByHash ¶
func (c *Commitlog) GetByHash(hKey uint32) *util.ByteStream
GetByHash returns ByteStream with requested data, nil if not found
func (*Commitlog) GetSummary ¶
GetSummary returns commitlog index
type DBManager ¶
type DBManager struct { Config *SparrowConfig // contains filtered or unexported fields }
DBManager holds all databases
func NewDBManager ¶
func NewDBManager(config *SparrowConfig, dbConfig *DatabaseConfig) *DBManager
NewDBManager returns new DBManager
func (*DBManager) CreateDatabase ¶
func (dbm *DBManager) CreateDatabase(descriptor DatabaseDescriptor) error
CreateDatabase create database
func (*DBManager) DropDatabase ¶
DropDatabase drop database
func (*DBManager) GetData ¶
func (dbm *DBManager) GetData(dbname string, strKey string) <-chan *model.DataDefinition
GetData returns pointer to DataDefinition and bool if found the data
func (*DBManager) GetDatabase ¶
GetDatabase returns database by database name
func (*DBManager) GetDatabasesNames ¶
GetDatabasesNames returns all databases names
func (*DBManager) LoadDatabases ¶
func (dbm *DBManager) LoadDatabases()
LoadDatabases loads databases from disk
type DataHolder ¶
type DataHolder struct {
// contains filtered or unexported fields
}
DataHolder definitive data file after commitlog flush
func NewDataHolder ¶
NewDataHolder returns new DataHolder pointer
func OpenDataHolder ¶
func OpenDataHolder(path string) (*DataHolder, error)
OpenDataHolder opens data holder for a given path
func (*DataHolder) Get ¶
func (d *DataHolder) Get(position int64) (*util.ByteStream, error)
Get get ByteStream from dataholder for a given position in data file
func (*DataHolder) GetSummary ¶
func (d *DataHolder) GetSummary() index.Summary
GetSummary get index summary of current data gile
type Database ¶
type Database struct { Descriptor DatabaseDescriptor // contains filtered or unexported fields }
Database holds database definitions
func NewDatabase ¶
func NewDatabase(descriptor DatabaseDescriptor) *Database
NewDatabase returns new Database
func OpenDatabase ¶
func OpenDatabase(descriptor DatabaseDescriptor) *Database
OpenDatabase returns oppened Database
func (*Database) GetDataByIndexEntry ¶
func (db *Database) GetDataByIndexEntry(dhIdx int, entry *index.Entry) (*model.DataDefinition, bool)
GetDataByIndexEntry get the image in data holder passing its index
func (*Database) GetDataByKey ¶
func (db *Database) GetDataByKey(key string) (*model.DataDefinition, bool)
GetDataByKey returns pointer to DataDefinition, bool if found the data and if found in data holder, return data holder index array, or if found in cache or commitlog return -1
func (*Database) GetDataIndexByKey ¶
GetDataIndexByKey search key in index, returns the index entry, data holder index or -1 if the key is in commitlog and bool if found.
func (*Database) Info ¶
func (db *Database) Info() DatabaseInfo
Info returns information about database
func (*Database) InsertCheckUpsert ¶
InsertCheckUpsert if df not exists insert it. If exits and is upsert, override old data
func (*Database) InsertData ¶
func (db *Database) InsertData(df *model.DataDefinition) error
InsertData insert data into database
type DatabaseConfig ¶
type DatabaseConfig struct {
// contains filtered or unexported fields
}
DatabaseConfig holds general configuration of database
func NewDatabaseConfig ¶
func NewDatabaseConfig(filePath string) *DatabaseConfig
NewDatabaseConfig return configuration from file
func (*DatabaseConfig) DropDatabase ¶
func (cfg *DatabaseConfig) DropDatabase(dbname string)
DropDatabase saves without database into the XML file
func (*DatabaseConfig) LoadDatabases ¶
func (cfg *DatabaseConfig) LoadDatabases() []DatabaseDescriptor
LoadDatabases load DatabaseConfigNode from XML file
func (*DatabaseConfig) SaveDatabase ¶
func (cfg *DatabaseConfig) SaveDatabase(database DatabaseDescriptor)
SaveDatabase saves DatabaseDescriptor into the XML file
type DatabaseDescriptor ¶
type DatabaseDescriptor struct { XMLName xml.Name `xml:"database"` Name string `xml:"name" valid:"alphanum,required,length(3|50)"` MaxDataLogSize uint64 `xml:"max_datalog_size"` MaxCacheSize uint64 `xml:"max_cache_size"` BloomFilterFp float32 `xml:"bloomfilter_fpp"` CronExp string `xml:"dataholder_cron_compaction"` Path string `xml:"path"` SnapshotPath string `xml:"snapshot_path"` TokenActive bool `xml:"generate_token"` ReadOnly bool `xml:"read_only"` }
DatabaseDescriptor holds database configuration
func (*DatabaseDescriptor) ToJSON ¶
func (dd *DatabaseDescriptor) ToJSON() []byte
ToJSON returns DatabaseDescriptor as JSON
type DatabaseInfo ¶
type DatabaseInfo struct { DhCount int `json:"datafile_count"` CommitlogSize int64 `json:"commitlog_size"` CacheItems int64 `json:"cache_item_count"` CacheUsed int64 `json:"cache_used_bytes"` }
DatabaseInfo returns database information
type SparrowConfig ¶
type SparrowConfig struct { NodeName string `xml:"node_name"` HTTPPort string `xml:"http_port"` HTTPHost string `xml:"http_host"` AdminPort string `xml:"admin_port"` AdminHost string `xml:"admin_host"` ReadOnly bool `xml:"read_only"` MaxDataLogSize uint64 `xml:"max_datalog_size"` MaxCacheSize uint64 `xml:"max_cache_size"` BloomFilterFp float32 `xml:"bloomfilter_fpp"` CronExp string `xml:"dataholder_cron_compaction"` Path string `xml:"data_file_directory"` SnapshotPath string `xml:"snapshot_path"` TokenActive bool `xml:"generate_token"` AuthenticationActive bool `xml:"enable_authentication"` UserExpire int `xml:"user_expire"` EnableWebUI bool `xml:"enable_webui"` }
SparrowConfig holds general configuration of SparrowDB
func NewSparrowConfig ¶
func NewSparrowConfig(filePath string) *SparrowConfig
NewSparrowConfig return configuration from file
type XMLDatabaseList ¶
type XMLDatabaseList struct { XMLName xml.Name `xml:"databases"` Databases []DatabaseDescriptor `xml:"database"` }
XMLDatabaseList holds root node and DatabaseDescriptor list