Documentation
¶
Index ¶
- Variables
- type PostgresLockAdapter
- func (i *PostgresLockAdapter) Acquire(ctx context.Context, key string, opts core.LockOptions) (*core.LockToken, error)
- func (p *PostgresLockAdapter) Close(ctx context.Context) error
- func (i *PostgresLockAdapter) GetSchemaStatus(ctx context.Context) (*schemaStatus, error)
- func (p *PostgresLockAdapter) HealthCheck(ctx context.Context) core.HealthReport
- func (i *PostgresLockAdapter) IsHeld(ctx context.Context, token *core.LockToken) (bool, time.Duration, error)
- func (i *PostgresLockAdapter) PrepareDbForMigrations(ctx context.Context) error
- func (i *PostgresLockAdapter) Refresh(ctx context.Context, token *core.LockToken, newTTL time.Duration) (*core.LockToken, error)
- func (i *PostgresLockAdapter) Release(ctx context.Context, token *core.LockToken) error
- func (i *PostgresLockAdapter) RunMigrations(ctx context.Context) error
- type PostgresLockerConfig
- func (p *PostgresLockerConfig) SetCreateSchemasIfNotExists(v bool) *PostgresLockerConfig
- func (p *PostgresLockerConfig) SetLockSchema(v string) *PostgresLockerConfig
- func (p *PostgresLockerConfig) SetLockTableName(v string) *PostgresLockerConfig
- func (p *PostgresLockerConfig) SetMigrationSchema(v string) *PostgresLockerConfig
- func (p *PostgresLockerConfig) SetMigrationTableName(v string) *PostgresLockerConfig
- func (p *PostgresLockerConfig) Validate() error
- func (p *PostgresLockerConfig) WithDefaults() *PostgresLockerConfig
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidConfig = errors.New("invalid configuration")
)
Functions ¶
This section is empty.
Types ¶
type PostgresLockAdapter ¶
type PostgresLockAdapter struct {
Cfg *PostgresLockerConfig
// contains filtered or unexported fields
}
func NewPostgresLockAdapter ¶
func NewPostgresLockAdapter( pool *pgxpool.Pool, cfg *PostgresLockerConfig, ) (*PostgresLockAdapter, error)
NewPostgresLockAdapter cria uma nova instância do adapter PostgreSQL
func (*PostgresLockAdapter) Acquire ¶
func (i *PostgresLockAdapter) Acquire(ctx context.Context, key string, opts core.LockOptions) (*core.LockToken, error)
func (*PostgresLockAdapter) Close ¶
func (p *PostgresLockAdapter) Close(ctx context.Context) error
Close the pgxPool
func (*PostgresLockAdapter) GetSchemaStatus ¶
func (i *PostgresLockAdapter) GetSchemaStatus(ctx context.Context) (*schemaStatus, error)
Returns the status of existance of the migration and lock schemas and tables
func (*PostgresLockAdapter) HealthCheck ¶
func (p *PostgresLockAdapter) HealthCheck(ctx context.Context) core.HealthReport
HealthCheck monitors service health. Throughput is the number of acquired connections and latency is the time taken to execute the query.
func (*PostgresLockAdapter) PrepareDbForMigrations ¶
func (i *PostgresLockAdapter) PrepareDbForMigrations(ctx context.Context) error
func (*PostgresLockAdapter) RunMigrations ¶
func (i *PostgresLockAdapter) RunMigrations(ctx context.Context) error
type PostgresLockerConfig ¶
type PostgresLockerConfig struct {
MigrationSchema string
MigrationTableName string
LockSchema string
LockTableName string
CreateSchemasIfNotExists bool
}
func NewPostgresLockerConfig ¶
func NewPostgresLockerConfig() *PostgresLockerConfig
NewPostgresLockerConfig creates a new instance of PostgresLockerConfig with default values.
CreateSchemasIfNotExists is set to true by default.
func (*PostgresLockerConfig) SetCreateSchemasIfNotExists ¶
func (p *PostgresLockerConfig) SetCreateSchemasIfNotExists(v bool) *PostgresLockerConfig
SetCreateSchemasIfNotExists sets the LockTableName field.
This method exists to allow functional options to set the field in fluent style.
func (*PostgresLockerConfig) SetLockSchema ¶
func (p *PostgresLockerConfig) SetLockSchema(v string) *PostgresLockerConfig
SetLockSchema sets the LockSchema field.
This method exists to allow functional options to set the field in fluent style.
func (*PostgresLockerConfig) SetLockTableName ¶
func (p *PostgresLockerConfig) SetLockTableName(v string) *PostgresLockerConfig
SetLockTableName sets the LockTableName field.
This method exists to allow functional options to set the field in fluent style.
func (*PostgresLockerConfig) SetMigrationSchema ¶
func (p *PostgresLockerConfig) SetMigrationSchema(v string) *PostgresLockerConfig
SetMigrationSchema sets the MigrationSchema field.
This method exists to allow functional options to set the field in fluent style.
func (*PostgresLockerConfig) SetMigrationTableName ¶
func (p *PostgresLockerConfig) SetMigrationTableName(v string) *PostgresLockerConfig
SetMigrationTableName sets the MigrationTableName field.
This method exists to allow functional options to set the field in fluent style.
func (*PostgresLockerConfig) Validate ¶
func (p *PostgresLockerConfig) Validate() error
func (*PostgresLockerConfig) WithDefaults ¶
func (p *PostgresLockerConfig) WithDefaults() *PostgresLockerConfig
WithDefaults sets default values for missing fields if they are not provided.
Returns the same instance Defaults:
- MigrationSchema: public
- MigrationTableName: locker_migrations
- LockSchema: public
- LockTableName: locker_locks