postgres

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package postgres contains an implementation of the storage.Backend backed by postgres.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseConfig added in v0.19.2

func ParseConfig(dsn string) (*pgxpool.Config, error)

ParseConfig parses a DSN into a pgxpool.Config.

Types

type Backend

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

Backend is a storage Backend implemented with Postgres.

func New

func New(dsn string, options ...Option) *Backend

New creates a new Backend.

func (*Backend) Close

func (backend *Backend) Close() error

Close closes the underlying database connection.

func (*Backend) Get

func (backend *Backend) Get(
	ctx context.Context,
	recordType, recordID string,
) (*databroker.Record, error)

Get gets a record from the database.

func (*Backend) GetOptions

func (backend *Backend) GetOptions(
	ctx context.Context,
	recordType string,
) (*databroker.Options, error)

GetOptions returns the options for the given record type.

func (*Backend) Lease

func (backend *Backend) Lease(
	ctx context.Context,
	leaseName, leaseID string,
	ttl time.Duration,
) (acquired bool, err error)

Lease attempts to acquire a lease for the given name.

func (*Backend) Put

func (backend *Backend) Put(
	ctx context.Context,
	records []*databroker.Record,
) (serverVersion uint64, err error)

Put puts a record into Postgres.

func (*Backend) RegistryServer

func (backend *Backend) RegistryServer() registry.RegistryServer

RegistryServer returns a registry.RegistryServer for the backend.

func (*Backend) SetOptions

func (backend *Backend) SetOptions(
	ctx context.Context,
	recordType string,
	options *databroker.Options,
) error

SetOptions sets the options for the given record type.

func (*Backend) Sync

func (backend *Backend) Sync(
	ctx context.Context,
	recordType string,
	serverVersion, recordVersion uint64,
) (storage.RecordStream, error)

Sync syncs the records.

func (*Backend) SyncLatest

func (backend *Backend) SyncLatest(
	ctx context.Context,
	recordType string,
	expr storage.FilterExpression,
) (serverVersion, recordVersion uint64, stream storage.RecordStream, err error)

SyncLatest syncs the latest version of each record.

type Option

type Option func(*config)

Option customizes a Backend.

func WithExpiry

func WithExpiry(expiry time.Duration) Option

WithExpiry sets the expiry for changes.

func WithRegistryTTL

func WithRegistryTTL(ttl time.Duration) Option

WithRegistryTTL sets the default registry TTL.

Jump to

Keyboard shortcuts

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