db

package
v0.0.0-...-968fa83 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMySqlDb

func InitMySqlDb(ctx context.Context, dbConfig config.RainDropDbConfig, l logger.ILogger) error

InitMySqlDb 初始化MySql

func InitPostgreSqlDb

func InitPostgreSqlDb(ctx context.Context, dbConfig config.RainDropDbConfig, l logger.ILogger) error

InitPostgreSqlDb 初始化PostgreSql

func InitTableWorkers

func InitTableWorkers(ctx context.Context, beginId int64, endId int64) error

Types

type IDb

type IDb interface {
	// InitSql 初始化
	InitSql(tableName string)

	// GetNowTime 获取数据库当前时间
	GetNowTime(ctx context.Context) (time.Time, error)

	// ExistTable 表是否存在
	ExistTable(ctx context.Context) (bool, error)

	// InitTableWorkers 初始化workers
	InitTableWorkers(ctx context.Context, beginId int64, endId int64) error

	// GetBeforeWorker 找到该节点之前的worker
	GetBeforeWorker(ctx context.Context, code string) (*model.RaindropWorker, error)

	// QueryFreeWorkers 查询空闲的workers
	QueryFreeWorkers(ctx context.Context, heartbeatTime time.Time) ([]model.RaindropWorker, error)

	// ActivateWorker 激活启用worker
	ActivateWorker(ctx context.Context, id int64, code string, timeUnit int, version int64) (*model.RaindropWorker, error)

	// HeartbeatWorker 心跳
	HeartbeatWorker(ctx context.Context, worker *model.RaindropWorker) (*model.RaindropWorker, error)

	// GetWorkerById 根据id获取worker
	GetWorkerById(ctx context.Context, id int64) (*model.RaindropWorker, error)
}
var (
	Db IDb
)

type MySqlDb

type MySqlDb struct {
	// contains filtered or unexported fields
}

func (*MySqlDb) ActivateWorker

func (m *MySqlDb) ActivateWorker(ctx context.Context, id int64, code string, timeUnit int, version int64) (*model.RaindropWorker, error)

ActivateWorker 激活启用worker

func (*MySqlDb) ExistTable

func (m *MySqlDb) ExistTable(ctx context.Context) (bool, error)

ExistTable 表是否存在

func (*MySqlDb) GetBeforeWorker

func (m *MySqlDb) GetBeforeWorker(ctx context.Context, code string) (*model.RaindropWorker, error)

GetBeforeWorker 找到该节点之前的worker

func (*MySqlDb) GetNowTime

func (m *MySqlDb) GetNowTime(ctx context.Context) (time.Time, error)

GetNowTime 获取数据库当前时间

func (*MySqlDb) GetWorkerById

func (m *MySqlDb) GetWorkerById(ctx context.Context, id int64) (*model.RaindropWorker, error)

GetWorkerById 根据id获取worker

func (*MySqlDb) HeartbeatWorker

func (m *MySqlDb) HeartbeatWorker(ctx context.Context, worker *model.RaindropWorker) (*model.RaindropWorker, error)

HeartbeatWorker 心跳

func (*MySqlDb) InitSql

func (m *MySqlDb) InitSql(tableName string)

func (*MySqlDb) InitTableWorkers

func (m *MySqlDb) InitTableWorkers(ctx context.Context, beginId int64, endId int64) error

InitTableWorkers 初始化数据

func (*MySqlDb) QueryFreeWorkers

func (m *MySqlDb) QueryFreeWorkers(ctx context.Context, heartbeatTime time.Time) ([]model.RaindropWorker, error)

QueryFreeWorkers 获取空闲的worker列表

type PostgreSqlDb

type PostgreSqlDb struct {
	// contains filtered or unexported fields
}

func (*PostgreSqlDb) ActivateWorker

func (m *PostgreSqlDb) ActivateWorker(ctx context.Context, id int64, code string, timeUnit int, version int64) (*model.RaindropWorker, error)

ActivateWorker 激活启用worker

func (*PostgreSqlDb) ExistTable

func (m *PostgreSqlDb) ExistTable(ctx context.Context) (bool, error)

ExistTable 表是否存在

func (*PostgreSqlDb) GetBeforeWorker

func (m *PostgreSqlDb) GetBeforeWorker(ctx context.Context, code string) (*model.RaindropWorker, error)

GetBeforeWorker 找到该节点之前的worker

func (*PostgreSqlDb) GetNowTime

func (m *PostgreSqlDb) GetNowTime(ctx context.Context) (time.Time, error)

GetNowTime 获取数据库当前时间

func (*PostgreSqlDb) GetWorkerById

func (m *PostgreSqlDb) GetWorkerById(ctx context.Context, id int64) (*model.RaindropWorker, error)

GetWorkerById 根据id获取worker

func (*PostgreSqlDb) HeartbeatWorker

func (m *PostgreSqlDb) HeartbeatWorker(ctx context.Context, worker *model.RaindropWorker) (*model.RaindropWorker, error)

HeartbeatWorker 心跳

func (*PostgreSqlDb) InitSql

func (m *PostgreSqlDb) InitSql(tableName string)

func (*PostgreSqlDb) InitTableWorkers

func (m *PostgreSqlDb) InitTableWorkers(ctx context.Context, beginId int64, endId int64) error

InitTableWorkers 初始化数据

func (*PostgreSqlDb) QueryFreeWorkers

func (m *PostgreSqlDb) QueryFreeWorkers(ctx context.Context, heartbeatTime time.Time) ([]model.RaindropWorker, error)

QueryFreeWorkers 获取空闲的worker列表

Jump to

Keyboard shortcuts

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