sqlserver_storage

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 10 Imported by: 2

README

SqlServer Storage

go get -u github.com/storage-lock/go-sqlserver-storage 

基于此Storage的锁的实现:

https://github.com/storage-lock/go-sqlserver-locks

Documentation

Index

Constants

View Source
const StorageName = "sql-server-storage"

Variables

This section is empty.

Functions

This section is empty.

Types

type SqlServerStorage

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

func NewSqlServerStorage

func NewSqlServerStorage(ctx context.Context, options *SqlServerStorageOptions) (*SqlServerStorage, error)

func (*SqlServerStorage) Close

func (x *SqlServerStorage) Close(ctx context.Context) error

func (*SqlServerStorage) DeleteWithVersion

func (x *SqlServerStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, lockInformation *storage.LockInformation) error

func (*SqlServerStorage) Get

func (x *SqlServerStorage) Get(ctx context.Context, lockId string) (string, error)

func (*SqlServerStorage) GetName

func (x *SqlServerStorage) GetName() string

func (*SqlServerStorage) GetTime

func (x *SqlServerStorage) GetTime(ctx context.Context) (time.Time, error)

func (*SqlServerStorage) Init

func (x *SqlServerStorage) Init(ctx context.Context) error

func (*SqlServerStorage) InsertWithVersion

func (x *SqlServerStorage) InsertWithVersion(ctx context.Context, lockId string, version storage.Version, lockInformation *storage.LockInformation) error

func (*SqlServerStorage) List

func (x *SqlServerStorage) List(ctx context.Context) (iterator.Iterator[*storage.LockInformation], error)

func (*SqlServerStorage) UpdateWithVersion

func (x *SqlServerStorage) UpdateWithVersion(ctx context.Context, lockId string, exceptedVersion, newVersion storage.Version, lockInformation *storage.LockInformation) error

type SqlServerStorageConnectionManager

type SqlServerStorageConnectionManager struct {

	// 主机的名字
	Host string

	// 主机的端口
	Port uint

	// 用户名
	User string

	// 密码
	Passwd string

	// DSN
	// Example: "sqlserver://sa:UeGqAm8CxYGldMDLoNNt@192.168.128.206:1433"
	DSN string
	// contains filtered or unexported fields
}

SqlServerStorageConnectionManager 创建一个SqlServer的连接

func NewSqlServerStorageConnectionGetter

func NewSqlServerStorageConnectionGetter(host string, port uint, user, passwd string) *SqlServerStorageConnectionManager

NewSqlServerStorageConnectionGetter 从服务器属性创建数据库连接

func NewSqlServerStorageConnectionGetterFromDSN

func NewSqlServerStorageConnectionGetterFromDSN(dsn string) *SqlServerStorageConnectionManager

NewSqlServerStorageConnectionGetterFromDSN 从DSN创建SqlServer连接

func (*SqlServerStorageConnectionManager) GetDSN

func (*SqlServerStorageConnectionManager) Name

func (*SqlServerStorageConnectionManager) Return

func (*SqlServerStorageConnectionManager) Shutdown

func (*SqlServerStorageConnectionManager) Take

Take 获取到数据库的连接

type SqlServerStorageOptions

type SqlServerStorageOptions struct {

	// 存放锁的表的名字
	TableName string

	// 用于获取数据库连接
	ConnectionManager storage.ConnectionManager[*sql.DB]
}

func NewSqlServerStorageOptions

func NewSqlServerStorageOptions() *SqlServerStorageOptions

func (*SqlServerStorageOptions) SetConnectionManage

func (x *SqlServerStorageOptions) SetConnectionManage(connectionManager storage.ConnectionManager[*sql.DB]) *SqlServerStorageOptions

func (*SqlServerStorageOptions) SetTableName

func (x *SqlServerStorageOptions) SetTableName(tableName string) *SqlServerStorageOptions

Jump to

Keyboard shortcuts

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