Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomID ¶
func GenerateRandomID() int64
Types ¶
type ConnConfig ¶
type ConnConfig struct { VpcDirectConnection bool Host string Port int32 DBName string User string Password string MaxConn int32 IsLocalEnv bool }
ConnConfig - InstanceManager configuration.
type InstanceManager ¶
type InstanceManager interface { GetDbConnPool() (any, error) GetConnFromPool(ctx context.Context) (any, error) CloseDbConnPool() GetConnectionConfig() ConnConfig Query(ctx context.Context, lockId int64, query string, args ...any) (*ResultSet, error) QueryAndProcess(ctx context.Context, lockId int64, processCallback func(row Row) error, query string, args ...any) error Exec(ctx context.Context, lockId int64, execQuery string, args ...any) (int64, error) TxBegin(ctx context.Context, lockId int64) (Transaction, error) ExecTransactionalTask(ctx context.Context, lockId int64, task func(ctx context.Context, tx Transaction) error) error AcquireDistributedLock(ctx context.Context, lockId int64) (int64, error) ReleaseDistributedLock(ctx context.Context, lockId int64) error ExecTaskWithDistributedLock(ctx context.Context, lockId int64, task func(ctx context.Context) error) error }
InstanceManager - InstanceManager interface.
type MasterReplicaManager ¶
type MasterReplicaManager struct { DbMaster InstanceManager DbReplica InstanceManager }
MasterReplicaManager - it manage master and read replica instance.
type PreparedStatement ¶
PreparedStatement - Prepared statement query.
func NewPreparedStatement ¶
func NewPreparedStatement(name, query string) PreparedStatement
NewPreparedStatement - Create new Prepared Statement.
func (PreparedStatement) GetName ¶
func (p PreparedStatement) GetName() string
GetName - name of the prepared statement.
func (PreparedStatement) GetQuery ¶
func (p PreparedStatement) GetQuery() string
GetQuery - query of the prepared statement.
type PreparedStatementsMap ¶
type PreparedStatementsMap struct {
DbPrepStmMap map[DbShard][]PreparedStatement
}
PreparedStatementsMap - map of DbShard and relative PreparedStatements.
type ResultSet ¶
ResultSet represents the query result set.
type ShardManager ¶
type ShardManager struct {
DbShardMap map[DbShard]MasterReplicaManager
}
ShardManager - it manage a pool of db shards, keeping them in a map. Each map value is a MasterReplicaManager.
func NewDbShardManager ¶
func NewDbShardManager() *ShardManager
NewDbShardManager is a constructor that ensures the inner map is always initialized.
func (*ShardManager) AddInstanceManager ¶
func (dsm *ShardManager) AddInstanceManager(dbShard DbShard, manager MasterReplicaManager)
AddInstanceManager adds a new MasterReplicaManager to the given DbShard.
type Transaction ¶
type Transaction interface { TxCommit(ctx context.Context, lockId int64) error TxRollback(ctx context.Context, lockId int64) TxQuery(ctx context.Context, query string, args ...any) (*ResultSet, error) TxExec(ctx context.Context, query string, args ...any) (int64, error) TxExecBatch(ctx context.Context, batch Batch) (int64, error) }
Transaction - transaction interface.