ccd

package
v0.0.0-...-6f8fa1e Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package ccd = core_config_data uses the MySQL based table core_config_data for reading and writing configuration paths, scopes and values.

It also provides an option function to load data from core_config_data into a storage service.

Index

Constants

View Source
const (
	TableIndexCoreConfigData = iota + 1 // Table: core_config_data
	TableIndexZZZ                       // the maximum index, which is not available.
)

TableIndex... is the index to a table. These constants are guaranteed to stay the same for all Magento versions. Please access a table via this constant instead of the raw table name. TableIndex iotas must start with 0.

Variables

View Source
var TableCollection *csdb.Tables

TableCollection handles all tables and its columns. init() in generated Go file will set the value.

Functions

func WithCoreConfigData

func WithCoreConfigData(dbrSess dbr.SessionRunner) config.Option

WithCoreConfigData reads the table core_config_data into the Service and overrides existing values. If the column `value` is NULL entry will be ignored. Stops on errors.

Types

type DBStorage

type DBStorage struct {

	// All is a SQL statement for the all keys query
	All *csdb.ResurrectStmt
	// Read is a SQL statement for selecting a value from a path/key
	Read *csdb.ResurrectStmt
	// Write statement inserts or updates a value
	Write *csdb.ResurrectStmt
	// contains filtered or unexported fields
}

DBStorage connects the MySQL DB with the config.Service type. Implements interface config.Storager.

func MustNewDBStorage

func MustNewDBStorage(p csdb.Preparer) *DBStorage

MustNewDBStorage same as NewDBStorage but panics on error. Implements interface config.Storager.

func NewDBStorage

func NewDBStorage(p csdb.Preparer) (*DBStorage, error)

NewDBStorage creates a new pointer with resurrecting prepared SQL statements. Default logger for the three underlying ResurrectStmt type sports to black hole.

All has an idle time of 15s. Read an idle time of 10s. Write an idle time of 30s. Implements interface config.Storager.

func (*DBStorage) AllKeys

func (dbs *DBStorage) AllKeys() (cfgpath.PathSlice, error)

AllKeys returns all available keys. Database errors get logged as info message.

func (*DBStorage) Get

func (dbs *DBStorage) Get(key cfgpath.Path) (interface{}, error)

Get returns a value from the database by its key. It is guaranteed that the type in the empty interface is a string. It returns nil on error but errors get logged as info message. Error behaviour: NotFound

func (*DBStorage) Set

func (dbs *DBStorage) Set(key cfgpath.Path, value interface{}) error

Set sets a value with its key. Database errors get logged as Info message. Enabled debug level logs the insert ID or rows affected.

func (*DBStorage) SetLogger

func (dbs *DBStorage) SetLogger(l log.Logger) *DBStorage

SetLogger applies your custom logger

func (*DBStorage) Start

func (dbs *DBStorage) Start() *DBStorage

Start starts the internal idle time checker for the resurrecting SQL statements.

func (*DBStorage) Stop

func (dbs *DBStorage) Stop() error

Stop stops the internal goroutines for idle time checking. Returns the first occurring sql.Stmt.Close() error.

type TableCoreConfigData

type TableCoreConfigData struct {
	ConfigID int64       `db:"config_id" json:",omitempty"` // config_id int(10) unsigned NOT NULL PRI  auto_increment
	Scope    string      `db:"scope" json:",omitempty"`     // scope varchar(8) NOT NULL MUL DEFAULT 'default'
	ScopeID  int64       `db:"scope_id" json:",omitempty"`  // scope_id int(11) NOT NULL  DEFAULT '0'
	Path     string      `db:"path" json:",omitempty"`      // path varchar(255) NOT NULL  DEFAULT 'general'
	Value    null.String `db:"value" json:",omitempty"`     // value text NULL
}

TableCoreConfigData represents a type for DB table core_config_data Generated via tableToStruct.

type TableCoreConfigDataSlice

type TableCoreConfigDataSlice []*TableCoreConfigData

TableCoreConfigDataSlice represents a collection type for DB table core_config_data Generated via tableToStruct.

Jump to

Keyboard shortcuts

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