Documentation ¶
Index ¶
- func InitMySqlDb(ctx context.Context, dbConfig config.RainDropDbConfig, l logger.ILogger) error
- func InitPostgreSqlDb(ctx context.Context, dbConfig config.RainDropDbConfig, l logger.ILogger) error
- func InitTableWorkers(ctx context.Context, beginId int64, endId int64) error
- type IDb
- type MySqlDb
- func (m *MySqlDb) ActivateWorker(ctx context.Context, id int64, code string, timeUnit int, version int64) (*model.RaindropWorker, error)
- func (m *MySqlDb) ExistTable(ctx context.Context) (bool, error)
- func (m *MySqlDb) GetBeforeWorker(ctx context.Context, code string) (*model.RaindropWorker, error)
- func (m *MySqlDb) GetNowTime(ctx context.Context) (time.Time, error)
- func (m *MySqlDb) GetWorkerById(ctx context.Context, id int64) (*model.RaindropWorker, error)
- func (m *MySqlDb) HeartbeatWorker(ctx context.Context, worker *model.RaindropWorker) (*model.RaindropWorker, error)
- func (m *MySqlDb) InitSql(tableName string)
- func (m *MySqlDb) InitTableWorkers(ctx context.Context, beginId int64, endId int64) error
- func (m *MySqlDb) QueryFreeWorkers(ctx context.Context, heartbeatTime time.Time) ([]model.RaindropWorker, error)
- type PostgreSqlDb
- func (m *PostgreSqlDb) ActivateWorker(ctx context.Context, id int64, code string, timeUnit int, version int64) (*model.RaindropWorker, error)
- func (m *PostgreSqlDb) ExistTable(ctx context.Context) (bool, error)
- func (m *PostgreSqlDb) GetBeforeWorker(ctx context.Context, code string) (*model.RaindropWorker, error)
- func (m *PostgreSqlDb) GetNowTime(ctx context.Context) (time.Time, error)
- func (m *PostgreSqlDb) GetWorkerById(ctx context.Context, id int64) (*model.RaindropWorker, error)
- func (m *PostgreSqlDb) HeartbeatWorker(ctx context.Context, worker *model.RaindropWorker) (*model.RaindropWorker, error)
- func (m *PostgreSqlDb) InitSql(tableName string)
- func (m *PostgreSqlDb) InitTableWorkers(ctx context.Context, beginId int64, endId int64) error
- func (m *PostgreSqlDb) QueryFreeWorkers(ctx context.Context, heartbeatTime time.Time) ([]model.RaindropWorker, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitMySqlDb ¶
InitMySqlDb 初始化MySql
func InitPostgreSqlDb ¶
func InitPostgreSqlDb(ctx context.Context, dbConfig config.RainDropDbConfig, l logger.ILogger) error
InitPostgreSqlDb 初始化PostgreSql
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 ¶
ExistTable 表是否存在
func (*MySqlDb) GetBeforeWorker ¶
GetBeforeWorker 找到该节点之前的worker
func (*MySqlDb) GetNowTime ¶
GetNowTime 获取数据库当前时间
func (*MySqlDb) GetWorkerById ¶
GetWorkerById 根据id获取worker
func (*MySqlDb) HeartbeatWorker ¶
func (m *MySqlDb) HeartbeatWorker(ctx context.Context, worker *model.RaindropWorker) (*model.RaindropWorker, error)
HeartbeatWorker 心跳
func (*MySqlDb) InitTableWorkers ¶
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 ¶
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 ¶
InitTableWorkers 初始化数据
func (*PostgreSqlDb) QueryFreeWorkers ¶
func (m *PostgreSqlDb) QueryFreeWorkers(ctx context.Context, heartbeatTime time.Time) ([]model.RaindropWorker, error)
QueryFreeWorkers 获取空闲的worker列表
Click to show internal directories.
Click to hide internal directories.