Documentation
¶
Index ¶
- Constants
- func GetTestPostgreSQLBackend(t *testing.T, logger log.Logger) (physical.Backend, func())
- func NewPostgreSQLBackend(conf map[string]string, logger log.Logger) (physical.Backend, error)
- func SetupDatabaseObjects(t *testing.T, pg *PostgreSQLBackend)
- type PostgreSQLBackend
- func (m *PostgreSQLBackend) Delete(ctx context.Context, fullPath string) error
- func (m *PostgreSQLBackend) Get(ctx context.Context, fullPath string) (*physical.Entry, error)
- func (p *PostgreSQLBackend) HAEnabled() bool
- func (m *PostgreSQLBackend) List(ctx context.Context, prefix string) ([]string, error)
- func (m *PostgreSQLBackend) ListPage(ctx context.Context, prefix string, after string, limit int) ([]string, error)
- func (p *PostgreSQLBackend) LockWith(key, value string) (physical.Lock, error)
- func (m *PostgreSQLBackend) Put(ctx context.Context, entry *physical.Entry) error
- type PostgreSQLLock
Constants ¶
const ( // The lock TTL matches the default that Consul API uses, 15 seconds. // Used as part of SQL commands to set/extend lock expiry time relative to // database clock. PostgreSQLLockTTLSeconds = 15 // The amount of time to wait between the lock renewals PostgreSQLLockRenewInterval = 5 * time.Second // PostgreSQLLockRetryInterval is the amount of time to wait // if a lock fails before trying again. PostgreSQLLockRetryInterval = time.Second )
Variables ¶
This section is empty.
Functions ¶
func NewPostgreSQLBackend ¶
NewPostgreSQLBackend constructs a PostgreSQL backend using the given API client, server address, credentials, and database.
func SetupDatabaseObjects ¶
func SetupDatabaseObjects(t *testing.T, pg *PostgreSQLBackend)
Types ¶
type PostgreSQLBackend ¶
type PostgreSQLBackend struct {
// contains filtered or unexported fields
}
PostgreSQL Backend is a physical backend that stores data within a PostgreSQL database.
func (*PostgreSQLBackend) Delete ¶
func (m *PostgreSQLBackend) Delete(ctx context.Context, fullPath string) error
Delete is used to permanently delete an entry
func (*PostgreSQLBackend) HAEnabled ¶
func (p *PostgreSQLBackend) HAEnabled() bool
func (*PostgreSQLBackend) List ¶
List is used to list all the keys under a given prefix, up to the next prefix.
func (*PostgreSQLBackend) ListPage ¶
func (m *PostgreSQLBackend) ListPage(ctx context.Context, prefix string, after string, limit int) ([]string, error)
ListPage is used to list all the keys under a given prefix, after the given key, up to the given key.
type PostgreSQLLock ¶
type PostgreSQLLock struct {
// contains filtered or unexported fields
}
PostgreSQLLock implements a lock using an PostgreSQL client.
func (*PostgreSQLLock) Lock ¶
func (l *PostgreSQLLock) Lock(stopCh <-chan struct{}) (<-chan struct{}, error)
Lock tries to acquire the lock by repeatedly trying to create a record in the PostgreSQL table. It will block until either the stop channel is closed or the lock could be acquired successfully. The returned channel will be closed once the lock in the PostgreSQL table cannot be renewed, either due to an error speaking to PostgreSQL or because someone else has taken it.
func (*PostgreSQLLock) Unlock ¶
func (l *PostgreSQLLock) Unlock() error
Unlock releases the lock by deleting the lock record from the PostgreSQL table.