Documentation
¶
Overview ¶
Package sqlstate 提供基于 ACT_GE_BYTEARRAY 的 SQL 状态存储。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB interface {
// ExecContext 执行语句。
// @param ctx 上下文
// @param query SQL
// @param args 参数
// @return 结果
// @return 错误
ExecContext(ctx context.Context, query string, args ...any) (Result, error)
// QueryContext 执行查询。
// @param ctx 上下文
// @param query SQL
// @param args 参数
// @return 结果集
// @return 错误
QueryContext(ctx context.Context, query string, args ...any) (Rows, error)
}
DB 是 SQL 执行接口,便于替换真实数据库与测试替身。
type Result ¶
type Result interface {
// RowsAffected 返回影响行数。
// @return 影响行数
// @return 错误
RowsAffected() (int64, error)
}
Result 是 SQL 执行结果。
type Rows ¶
type Rows interface {
// Next 前进到下一行。
// @return 是否有下一行
Next() bool
// Scan 扫描当前行。
// @param dest 目标
// @return 扫描错误
Scan(dest ...any) error
// Close 关闭结果集。
// @return 关闭错误
Close() error
// Err 返回遍历错误。
// @return 遍历错误
Err() error
}
Rows 是查询结果集。
type SQLDB ¶
SQLDB 将 *sql.DB 适配为 DB 接口。
func (SQLDB) ExecContext ¶
ExecContext 执行语句。 @param ctx 上下文 @param query SQL @param args 参数 @return 结果 @return 错误
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 将引擎状态快照存入 ACT_GE_BYTEARRAY。
func NewExclusiveMySQL ¶
func NewExclusiveMySQL(ctx context.Context, db *sql.DB, namespace string) (*Store, func() error, error)
NewExclusiveMySQL 获取快照独占连接;其他进程占用时立即拒绝启动。 @param ctx 初始化上下文 @param db 数据库连接池 @param namespace 数据库名称 @return 快照存储 @return 幂等释放函数 @return 获取错误
func (*Store) CheckOwner ¶
CheckOwner 在底层具备独占会话时验证其所有权。 @param ctx 上下文 @return 所有权错误
Click to show internal directories.
Click to hide internal directories.