Documentation
¶
Index ¶
- Constants
- Variables
- type Sql92Provider
- func (x *Sql92Provider) CreateTableSql(ctx context.Context, tableFullName string) (string, []any)
- func (x *Sql92Provider) CreateWithVersionSql(ctx context.Context, tableFullName string, lockId string, ...) (string, []any)
- func (x *Sql92Provider) DeleteWithVersionSql(ctx context.Context, tableFullName string, lockId string, ...) (string, []any)
- func (x *Sql92Provider) FindLockInformationJsonStringByIdSql(ctx context.Context, tableFullName string, lockId string) (string, []any)
- func (x *Sql92Provider) ListLockInformationJsonStringSql(ctx context.Context, tableFullName string) (string, []any)
- func (x *Sql92Provider) NowTimestampSql(ctx context.Context, tableFullName string) (string, []any)
- func (x *Sql92Provider) UpdateWithVersionSql(ctx context.Context, tableFullName string, lockId string, ...) (string, []any)
- type SqlBasedStorage
- func (x *SqlBasedStorage) Close(ctx context.Context) error
- func (x *SqlBasedStorage) CreateWithVersion(ctx context.Context, lockId string, version storage.Version, ...) (returnError error)
- func (x *SqlBasedStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, ...) (returnError error)
- func (x *SqlBasedStorage) Get(ctx context.Context, lockId string) (lockInformationJsonString string, returnError error)
- func (x *SqlBasedStorage) GetName() string
- func (x *SqlBasedStorage) GetTime(ctx context.Context) (now time.Time, returnError error)
- func (x *SqlBasedStorage) Init(ctx context.Context) (returnError error)
- func (x *SqlBasedStorage) List(ctx context.Context) (iterator iterator.Iterator[*storage.LockInformation], returnError error)
- func (x *SqlBasedStorage) UpdateWithVersion(ctx context.Context, lockId string, ...) (returnError error)
- type SqlBasedStorageOptions
- func (x *SqlBasedStorageOptions) Check() error
- func (x *SqlBasedStorageOptions) SetConnectionManager(connectionManager storage.ConnectionManager[*sql.DB]) *SqlBasedStorageOptions
- func (x *SqlBasedStorageOptions) SetSqlProvider(sqlProvider SqlProvider) *SqlBasedStorageOptions
- func (x *SqlBasedStorageOptions) SetTableFullName(tableFullName string) *SqlBasedStorageOptions
- type SqlProvider
Constants ¶
View Source
const StorageName = "sql-based-storage"
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Sql92Provider ¶
type Sql92Provider struct { }
Sql92Provider SQL Provider的一个实现,SQL92标准
func NewSql92Provider ¶
func NewSql92Provider() *Sql92Provider
func (*Sql92Provider) CreateTableSql ¶
func (*Sql92Provider) CreateWithVersionSql ¶
func (*Sql92Provider) DeleteWithVersionSql ¶
func (*Sql92Provider) FindLockInformationJsonStringByIdSql ¶
func (*Sql92Provider) ListLockInformationJsonStringSql ¶
func (*Sql92Provider) NowTimestampSql ¶
func (*Sql92Provider) UpdateWithVersionSql ¶
type SqlBasedStorage ¶
type SqlBasedStorage struct {
// contains filtered or unexported fields
}
SqlBasedStorage 基于SQL实现的Storage的抽象实现
func NewSqlBasedStorage ¶
func NewSqlBasedStorage(options *SqlBasedStorageOptions) (*SqlBasedStorage, error)
func (*SqlBasedStorage) Close ¶
func (x *SqlBasedStorage) Close(ctx context.Context) error
Close 释放Storage占用的资源
func (*SqlBasedStorage) CreateWithVersion ¶
func (x *SqlBasedStorage) CreateWithVersion(ctx context.Context, lockId string, version storage.Version, lockInformation *storage.LockInformation) (returnError error)
func (*SqlBasedStorage) DeleteWithVersion ¶
func (x *SqlBasedStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, lockInformation *storage.LockInformation) (returnError error)
func (*SqlBasedStorage) GetName ¶
func (x *SqlBasedStorage) GetName() string
func (*SqlBasedStorage) Init ¶
func (x *SqlBasedStorage) Init(ctx context.Context) (returnError error)
func (*SqlBasedStorage) List ¶
func (x *SqlBasedStorage) List(ctx context.Context) (iterator iterator.Iterator[*storage.LockInformation], returnError error)
List 列出当前存储的所有的锁
func (*SqlBasedStorage) UpdateWithVersion ¶
func (x *SqlBasedStorage) UpdateWithVersion(ctx context.Context, lockId string, exceptedVersion, newVersion storage.Version, lockInformation *storage.LockInformation) (returnError error)
type SqlBasedStorageOptions ¶
type SqlBasedStorageOptions struct { // 用于提供SQL SqlProvider SqlProvider // 用于管理连接 ConnectionManager storage.ConnectionManager[*sql.DB] // 存储锁的表的名称 TableFullName string }
func NewSqlBasedStorageOptions ¶
func NewSqlBasedStorageOptions() *SqlBasedStorageOptions
func (*SqlBasedStorageOptions) Check ¶
func (x *SqlBasedStorageOptions) Check() error
func (*SqlBasedStorageOptions) SetConnectionManager ¶
func (x *SqlBasedStorageOptions) SetConnectionManager(connectionManager storage.ConnectionManager[*sql.DB]) *SqlBasedStorageOptions
func (*SqlBasedStorageOptions) SetSqlProvider ¶
func (x *SqlBasedStorageOptions) SetSqlProvider(sqlProvider SqlProvider) *SqlBasedStorageOptions
func (*SqlBasedStorageOptions) SetTableFullName ¶
func (x *SqlBasedStorageOptions) SetTableFullName(tableFullName string) *SqlBasedStorageOptions
type SqlProvider ¶
type SqlProvider interface { // CreateTableSql 返回创建存储锁的表的SQL,创建时请根据需要自行设置主键约束 CreateTableSql(ctx context.Context, tableFullName string) (string, []any) // UpdateWithVersionSql 根据LockId、Version更新LockInformation的SQL UpdateWithVersionSql(ctx context.Context, tableFullName string, lockId string, exceptedVersion, newVersion storage.Version, lockInformation *storage.LockInformation) (string, []any) // CreateWithVersionSql 根据LockId、Version创建LockInformation的SQL CreateWithVersionSql(ctx context.Context, tableFullName string, lockId string, version storage.Version, lockInformation *storage.LockInformation) (string, []any) // DeleteWithVersionSql 根据LockId和Version删除锁信息的SQL DeleteWithVersionSql(ctx context.Context, tableFullName string, lockId string, exceptedVersion storage.Version, lockInformation *storage.LockInformation) (string, []any) // NowTimestampSql 获取Storage当前时间的Unix时间戳的SQL NowTimestampSql(ctx context.Context, tableFullName string) (string, []any) // FindLockInformationJsonStringByIdSql 根据LockId查询锁信息的JsonString的SQL FindLockInformationJsonStringByIdSql(ctx context.Context, tableFullName string, lockId string) (string, []any) // ListLockInformationJsonStringSql 返回能够列出所有的锁的JsonString的SQL ListLockInformationJsonStringSql(ctx context.Context, tableFullName string) (string, []any) }
SqlProvider 用于提供各种用途的SQl方言
Source Files
¶
Click to show internal directories.
Click to hide internal directories.