Documentation ¶
Index ¶
- Constants
- Variables
- func Initialize(ctx context.Context, appName string, statsHandler stats.Handler)deprecated
- func InitializeWithConfig(ctx context.Context, cfg Config)
- type Config
- type LDBReader
- func (reader *LDBReader) Close() error
- func (reader *LDBReader) GetLastSequence(ctx context.Context) (schema.DMLSequence, error)
- func (reader *LDBReader) GetLedgerLatency(ctx context.Context) (time.Duration, error)
- func (reader *LDBReader) GetRowByKey(ctx context.Context, out interface{}, familyName string, tableName string, ...) (found bool, err error)
- func (reader *LDBReader) GetRowsByKeyPrefix(ctx context.Context, familyName string, tableName string, key ...interface{}) (*Rows, error)
- func (reader *LDBReader) Ping(ctx context.Context) bool
- type LDBTestTableDef
- type LDBTestUtil
- type Rows
Constants ¶
const ( DefaultCtlstorePath = "/var/spool/ctlstore/" DefaultChangelogFilename = "change.log" )
Variables ¶
var ( ErrTableHasNoPrimaryKey = errors.New("Table provided has no primary key") ErrNeedFullKey = errors.New("All primary key fields are required") ErrNoLedgerUpdates = errors.New("no ledger updates have been received yet") )
var Version string
Version is the current ctlstore client library version.
Functions ¶
func Initialize
deprecated
func InitializeWithConfig ¶
InitializeWithConfig sets up global state for thing including global metrics globalstats data and possibly more as time goes on.
Types ¶
type Config ¶
type Config struct { // Stats specifies the config for reporting stats to the global // ctlstore stats namespace. // // By default, global stats are enabled with a set of sane defaults. Stats *globalstats.Config // LDBVersioning, if enabled, will instruct ctlstore to look for // LDBs inside of timestamp-delimited folders, and ctlstore will // hot-reload new LDBs as they appear. // // By default, this is disabled. LDBVersioning bool }
type LDBReader ¶
LDBReader reads data from the LDB. The external interface is thread-safe and it is safe to create as many of these as needed across multiple processes.
func NewLDBReaderFromDB ¶
Constructs an LDBReader from a sql.DB. Really only useful for testing.
func ReaderForPath ¶
ReaderForPath opens an LDB at the provided path and returns an LDBReader instance pointed at that LDB.
func (*LDBReader) GetLastSequence ¶
GetLastSequence returns the highest sequence number applied to the DB
func (*LDBReader) GetLedgerLatency ¶
GetLedgerLatency returns the difference between the current time and the timestamp from the last DML ledger update processed by the reflector. ErrNoLedgerUpdates will be returned if no DML statements have been processed.
func (*LDBReader) GetRowByKey ¶
func (reader *LDBReader) GetRowByKey( ctx context.Context, out interface{}, familyName string, tableName string, key ...interface{}, ) (found bool, err error)
GetRowByKey fetches a row from the supplied table by the key parameter, filling the data into the out param.
The out param may be one of the following types:
- pointer to struct
- map[string]interface{}
The key parameter can support composite keys by passing a slice type.
func (*LDBReader) GetRowsByKeyPrefix ¶
func (reader *LDBReader) GetRowsByKeyPrefix(ctx context.Context, familyName string, tableName string, key ...interface{}) (*Rows, error)
GetRowsByKeyPrefix returns a *Rows iterator that will supply all of the rows in the family and table match the supplied primary key prefix.
type LDBTestTableDef ¶
type LDBTestTableDef struct { Family string Name string Fields [][]string KeyFields []string Rows [][]interface{} }
LDBTestTableDef is used to pass a table definition to CreateTable for use in tests that need the LDB. The way the parameters are specified mimics the executive interface. Fields are passed as tuples of [name string, type string] where type can be something like "string" or "integer," just like the standard executive interface.
type LDBTestUtil ¶
LDBTestUtil provides basic unit testing facilities for injecting data into a "fake" LDB.
func NewLDBTestUtil ¶
func NewLDBTestUtil(t testing.TB) (*LDBTestUtil, func())
NewLDBTestUtil changes the global default LDB path to a temporary path.
This function is NOT concurrency safe.
func NewLDBTestUtilLocal ¶ added in v0.0.2
func NewLDBTestUtilLocal(t testing.TB) (*LDBTestUtil, func())
NewLDBTestUtilLocal is just like NewLDBTestUtil above except it does not rely on global state and is therefore threadsafe, at the cost of requiring users to use ensure that the DB property is used to initialize the ctlstore Reader instead of relying on the global/default init.
func (*LDBTestUtil) CreateTable ¶
func (tu *LDBTestUtil) CreateTable(def LDBTestTableDef)
CreateTable creates a table in the target test LDB.
func (*LDBTestUtil) DeleteAll ¶
func (tu *LDBTestUtil) DeleteAll(family string, table string)
DeleteAll deletes all rows from the given table.
func (*LDBTestUtil) InsertRows ¶
func (tu *LDBTestUtil) InsertRows(family string, table string, rows [][]interface{})
InsertRows well, inserts rows into the LDB. Rows are passed as tuples in the table's column order.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows composes an *sql.Rows and allows scanning ctlstore table rows into structs or maps, similar to how the GetRowByKey reader method works.
The contract around Next/Err/Close is the same was it is for *sql.Rows.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
pkg
|
|
cmd/ctlstore-mutator
This program sends constant load to the executive service.
|
This program sends constant load to the executive service. |
executive/fakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
fakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
globalstats
Package globalstats provides configurable singleton stats instance for ctlstore.
|
Package globalstats provides configurable singleton stats instance for ctlstore. |
ledger/fakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
supervisor/fakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
utils
this package hosts utilities that probably don't belong elsewhere.
|
this package hosts utilities that probably don't belong elsewhere. |