Documentation
¶
Index ¶
- Constants
- type PostgreSQLConnectionManager
- func (x *PostgreSQLConnectionManager) GetDSN() string
- func (x *PostgreSQLConnectionManager) Name() string
- func (x *PostgreSQLConnectionManager) Return(ctx context.Context, connection *sql.DB) error
- func (x *PostgreSQLConnectionManager) Shutdown(ctx context.Context) error
- func (x *PostgreSQLConnectionManager) Take(ctx context.Context) (*sql.DB, error)
- type PostgreSQLStorage
- func (x *PostgreSQLStorage) Close(ctx context.Context) error
- func (x *PostgreSQLStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, ...) error
- func (x *PostgreSQLStorage) Get(ctx context.Context, lockId string) (string, error)
- func (x *PostgreSQLStorage) GetName() string
- func (x *PostgreSQLStorage) GetTime(ctx context.Context) (time.Time, error)
- func (x *PostgreSQLStorage) Init(ctx context.Context) error
- func (x *PostgreSQLStorage) InsertWithVersion(ctx context.Context, lockId string, version storage.Version, ...) error
- func (x *PostgreSQLStorage) List(ctx context.Context) (iterator.Iterator[*storage.LockInformation], error)
- func (x *PostgreSQLStorage) UpdateWithVersion(ctx context.Context, lockId string, ...) error
- type PostgreSQLStorageOptions
- func (x *PostgreSQLStorageOptions) SetConnectionManager(connectionManager storage.ConnectionManager[*sql.DB]) *PostgreSQLStorageOptions
- func (x *PostgreSQLStorageOptions) SetSchema(schema string) *PostgreSQLStorageOptions
- func (x *PostgreSQLStorageOptions) SetTableName(tableName string) *PostgreSQLStorageOptions
Constants ¶
View Source
const DefaultPostgreSQLStorageSchema = "public"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgreSQLConnectionManager ¶
type PostgreSQLConnectionManager struct { // 主机的名字 Host string // 主机的端口 Port uint // 用户名 User string // 密码 Passwd string DatabaseName string // DSN // Example: "host=192.168.128.206 user=postgres password=123456 port=5432 dbname=postgres sslmode=disable" DSN string // contains filtered or unexported fields }
func NewPostgreSQLConnectionGetter ¶
func NewPostgreSQLConnectionGetter(host string, port uint, user, passwd, databaseName string) *PostgreSQLConnectionManager
NewPostgreSQLConnectionGetter 从服务器属性创建数据库连接
func NewPostgreSQLConnectionGetterFromDSN ¶
func NewPostgreSQLConnectionGetterFromDSN(dsn string) *PostgreSQLConnectionManager
NewPostgreSQLConnectionGetterFromDSN 从DSN创建MySQL连接
func (*PostgreSQLConnectionManager) GetDSN ¶
func (x *PostgreSQLConnectionManager) GetDSN() string
func (*PostgreSQLConnectionManager) Name ¶
func (x *PostgreSQLConnectionManager) Name() string
type PostgreSQLStorage ¶
type PostgreSQLStorage struct {
// contains filtered or unexported fields
}
PostgreSQLStorage 基于Postgresql作为存储引擎
func NewPostgreSQLStorage ¶
func NewPostgreSQLStorage(ctx context.Context, options *PostgreSQLStorageOptions) (*PostgreSQLStorage, error)
func (*PostgreSQLStorage) DeleteWithVersion ¶
func (x *PostgreSQLStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, lockInformation *storage.LockInformation) error
func (*PostgreSQLStorage) GetName ¶
func (x *PostgreSQLStorage) GetName() string
func (*PostgreSQLStorage) InsertWithVersion ¶
func (x *PostgreSQLStorage) InsertWithVersion(ctx context.Context, lockId string, version storage.Version, lockInformation *storage.LockInformation) error
func (*PostgreSQLStorage) List ¶
func (x *PostgreSQLStorage) List(ctx context.Context) (iterator.Iterator[*storage.LockInformation], error)
func (*PostgreSQLStorage) UpdateWithVersion ¶
func (x *PostgreSQLStorage) UpdateWithVersion(ctx context.Context, lockId string, exceptedVersion, newVersion storage.Version, lockInformation *storage.LockInformation) error
type PostgreSQLStorageOptions ¶
type PostgreSQLStorageOptions struct { // 存在哪个schema下,默认是public Schema string // 存放锁的表的名字 TableName string // 用于获取数据库连接 ConnectionManager storage.ConnectionManager[*sql.DB] }
func NewPostgreSQLStorageOptions ¶
func NewPostgreSQLStorageOptions() *PostgreSQLStorageOptions
func (*PostgreSQLStorageOptions) SetConnectionManager ¶
func (x *PostgreSQLStorageOptions) SetConnectionManager(connectionManager storage.ConnectionManager[*sql.DB]) *PostgreSQLStorageOptions
func (*PostgreSQLStorageOptions) SetSchema ¶
func (x *PostgreSQLStorageOptions) SetSchema(schema string) *PostgreSQLStorageOptions
func (*PostgreSQLStorageOptions) SetTableName ¶
func (x *PostgreSQLStorageOptions) SetTableName(tableName string) *PostgreSQLStorageOptions
Click to show internal directories.
Click to hide internal directories.