pg

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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) IsHeld

func (*PostgresLockAdapter) PrepareDbForMigrations

func (i *PostgresLockAdapter) PrepareDbForMigrations(ctx context.Context) error

func (*PostgresLockAdapter) Refresh

func (i *PostgresLockAdapter) Refresh(ctx context.Context, token *core.LockToken, newTTL time.Duration) (*core.LockToken, error)

func (*PostgresLockAdapter) Release

func (i *PostgresLockAdapter) Release(ctx context.Context, token *core.LockToken) 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

Jump to

Keyboard shortcuts

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