state

package
v0.0.0-...-ab40c3c Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close deinitializes the state

func Connect

func Connect(cfg *config.AppConfig) bool

Connect connects to state DB. Returns false if connection failed

Exported for lock test

func ConnectInfoGet

func ConnectInfoGet(l *db.Loc, tp int) *db.Addr

ConnectInfoGet resolves database address using state clusters table

func ConnectLow

func ConnectLow(cfg *config.AppConfig, nodb bool) *sql.DB

ConnectLow resolve address and connects to the state DB It can use state_connect_url config option, or using db.GetInfo resolver as any other database in the system

func DeleteClusterInfo

func DeleteClusterInfo(name string) error

DeleteClusterInfo delete cluster connection onfo from state database

func DeleteSchema

func DeleteSchema(name string, typ string) error

DeleteSchema deletes output schema from the state

func DeregisterTable

func DeregisterTable(svc string, sdb string, table string, input string, output string, version int) bool

DeregisterTable removes given table from the state

func GetCount

func GetCount() (int, error)

GetCount returns number of rows in the state

func GetCurrentGTID

func GetCurrentGTID(a *db.Addr) (gtid string, err error)

GetCurrentGTID returns current gtid set for the specified db address (host,port,user,password) FIXME: move to db package

func GetCurrentGTIDForDB

func GetCurrentGTIDForDB(l *db.Loc) (string, error)

GetCurrentGTIDForDB return current gtid set for the db specified by db locator (cluster,service,db) FIXME: move to db package

func GetDB

func GetDB() *sql.DB

GetDB returns active db connection to the state

func GetDbAddr

func GetDbAddr() *db.Addr

GetDbAddr return low level address of the database: Host, Port, User, Password

func GetGTID

func GetGTID(d *db.Loc) (gtid string, err error)

GetGTID returns GTID saved in the state for given db locator

func GetNoDB

func GetNoDB() *sql.DB

GetNoDB returns active connection to the state database server Without connecting to any specific db

func GetOutputSchema

func GetOutputSchema(name string, typ string) string

GetOutputSchema returns output schema from the state

func GetSchema

func GetSchema(svc string, sdb string, table string) (*types.TableSchema, error)

GetSchema return structured schema saved in the state for give table

func GetTableNewFlag

func GetTableNewFlag(service, cluster, db, table, input, output string, version int) (n bool, err error)

GetTableNewFlag returns the flag indicating whether the table has a snapshot

func GetVersion

func GetVersion() int64

GetVersion track the state changes Return value changes when something got changed in the state, new tables inserted or removed It doesn't guarantee that return value will increase monotonically

func Init

func Init(cfg *config.AppConfig) bool

Init does complete state initialization. Create and connect to database

func InsertClusterInfo

func InsertClusterInfo(name string, ci *db.Addr) error

InsertClusterInfo adds connection information for the cluster "name" to state

func InsertSchema

func InsertSchema(name string, typ string, schema string) error

InsertSchema inserts output schema into state

func RegisterTable

func RegisterTable(dbl *db.Loc, table string, input string, output string, version int, outputFormat string) bool

RegisterTable adds table to the state

func ReplaceSchema

func ReplaceSchema(svc string, cluster string, s *types.TableSchema, rawSchema string, oldGTID string, gtid string, input string, output string, version int, outputFormat string) bool

ReplaceSchema replaces both dtructured and raw schema definitions saved in the state with new versions provided as parameters If oldGtid is empty adds it as new table to the state FIXME: To big function. Split it.

func SaveBinlogState

func SaveBinlogState(d *db.Loc, gtid string, seqNo uint64) error

SaveBinlogState saves current state of the binlog reader to the state DB binlog state is current GTID set and current seqNo

func SetGTID

func SetGTID(d *db.Loc, gtid string) error

SetGTID saves given gtid for given db locator

func SetTableNewFlag

func SetTableNewFlag(service, cluster, db, table, input, output string, version int, flag bool) error

SetTableNewFlag sets flag indicating that streamer has taken a snapshot of table

func TableRegistered

func TableRegistered(id int64) (bool, error)

TableRegistered checks if table with given id is still registered in the state Table id is id field from row structure

func UpdateSchema

func UpdateSchema(name string, typ string, schema string) error

UpdateSchema inserts output schema into state

Types

type Type

type Type []row

Type is in-memory representation of state

func Get

func Get() (Type, error)

Get returns all the rows in the state

func GetCond

func GetCond(cond string, args ...interface{}) (Type, error)

GetCond returns rows with given condition in the state

func GetForCluster

func GetForCluster(cluster string) (Type, error)

GetForCluster returns state rows for given cluster name

func GetTable

func GetTable(service string, db string, table string) (Type, error)

GetTable returns state rows for given service,db,table

func GetTableByID

func GetTableByID(id int64) (Type, error)

GetTableByID return state row for the given table id

Jump to

Keyboard shortcuts

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