postgres

package
v0.69.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DriverName = "postgres"

	DefaultTableName = "kv"

	// DefaultPartitions Changing the below value means repartitioning and probably a migration.
	// Change it only if you really know what you're doing.
	DefaultPartitions = 100
)

Variables

View Source
var ErrAlreadyMigrated = errors.New("already migrated")

Functions

func Migrate added in v0.66.0

func Migrate(ctx context.Context, dbPool *pgxpool.Pool, dbParams params.Database) error

Migrate data migration from DB to KV

func RegisterMigrate added in v0.66.0

func RegisterMigrate(name string, f MigrateFunc, tables []string)

func UnregisterAll added in v0.66.0

func UnregisterAll()

UnregisterAll remove all loaded migrate callbacks, used for test code.

Types

type Driver

type Driver struct{}

func (*Driver) Open

func (d *Driver) Open(ctx context.Context, kvparams kvparams.KV) (kv.Store, error)

type EntriesIterator

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

func (*EntriesIterator) Close

func (e *EntriesIterator) Close()

func (*EntriesIterator) Entry

func (e *EntriesIterator) Entry() *kv.Entry

func (*EntriesIterator) Err

func (e *EntriesIterator) Err() error

Err return the last scan error or the cursor error

func (*EntriesIterator) Next

func (e *EntriesIterator) Next() bool

Next reads the next key/value.

type MigrateFunc added in v0.66.0

type MigrateFunc func(ctx context.Context, db *pgxpool.Pool, writer io.Writer) error

type Params

type Params struct {
	TableName          string
	SanitizedTableName string
	PartitionsAmount   int
}

type Store

type Store struct {
	Pool           *pgxpool.Pool
	Params         *Params
	TableSanitized string
}

func (*Store) Close

func (s *Store) Close()

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, partitionKey, key []byte) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, partitionKey, key []byte) (*kv.ValueWithPredicate, error)

func (*Store) Scan

func (s *Store) Scan(ctx context.Context, partitionKey, start []byte) (kv.EntriesIterator, error)

func (*Store) Set

func (s *Store) Set(ctx context.Context, partitionKey, key, value []byte) error

func (*Store) SetIf

func (s *Store) SetIf(ctx context.Context, partitionKey, key, value []byte, valuePredicate kv.Predicate) error

Jump to

Keyboard shortcuts

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