tablemanager

package
v0.0.0-...-2ecc45d Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
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

type Config struct {
	TimeoutMs int64
	MaxRows   int64
	Persist   bool
}

Config has viable for TableManager fields like timeout and max rows

func NewConfig

func NewConfig(timeoutMs int64, maxRows int64, persist bool) Config

NewConfig returns a ready to use config

func (Config) Validate

func (c Config) Validate() error

Validate checks if config is valid

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

func (h *Holder) Append(ts *table.Signature, config Config, sync bool, rowsJSON []byte) error

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

func (h *Holder) StopTableManagers() []error

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

Jump to

Keyboard shortcuts

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