Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //ErrZeroTimeoutMs means that timeout ms is 0 ErrZeroTimeoutMs = errors.New("timeout_ms couldn't be zero") //ErrZeroMaxRows means that maxRows is 0 ErrZeroMaxRows = errors.New("max_rows couldn't be zero") //ErrPersistNotFalse means that persist is not false (persist is yet not supported) ErrPersistNotFalse = errors.New("persist is not yet supported") )
var ErrTableManagerDidntStopInTime = errors.New("didn't stop in time")
ErrTableManagerDidntStopInTime means table manager didn't stop in time
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config has viable for TableManager fields like timeout and max rows
type Holder ¶
type Holder struct {
// contains filtered or unexported fields
}
Holder creates table managers, holds pointers to them, stops them when they are not used for a long time. Serves as frontend to table managers.
func NewHolder ¶
func NewHolder(errChan chan error, inserters map[string]inserter.Inserter, insertErrorLogger *inserter.InsertErrorLogger) *Holder
NewHolder creates new holder
func (*Holder) Append ¶
Append searches for an existing table manager or creates it, then calls it's AppendRowsToTable. If sync is true, always creates a new manager and instantly calls DoInsert.
func (*Holder) StopTableManagers ¶
StopTableManagers stops existing table managers with timeout. If one of them didn't stop in time or has insert errors returns them.
func (*Holder) StopUnusedManagers ¶
func (h *Holder) StopUnusedManagers()
StopUnusedManagers starts a goroutine which stops unused table managers periodically.
type TableManager ¶
type TableManager struct {
// contains filtered or unexported fields
}
TableManager is responsible for a table and calling inserters on it. Serves as frontend to a table
func NewTableManager ¶
func NewTableManager(ts *table.Signature, config Config, inserters map[string]inserter.Inserter, insertErrorLogger *inserter.InsertErrorLogger) *TableManager
NewTableManager returns configured table manager
func (*TableManager) AppendRowsToTable ¶
func (tm *TableManager) AppendRowsToTable(rowsJSON []byte) error
AppendRowsToTable is a frontend for table's AppendRows. If maxRows is reached sends signal to start inserting (see Run)
func (*TableManager) DoInsert ¶
func (tm *TableManager) DoInsert() (err error)
DoInsert creates a new table and calls inserters on the old
func (*TableManager) Run ¶
func (tm *TableManager) Run()
Run is manager's main loop where is waiting for time limit or a signal to insert. The place where inserts should be fired
func (*TableManager) Stop ¶
func (tm *TableManager) Stop()
Stop sends a signal in main loop to insert, waits for response (which means the main loop is finished)
func (*TableManager) UpdateConfig ¶
func (tm *TableManager) UpdateConfig(config Config)
UpdateConfig updates maxRows and timeoutMs from config. Thread safe