pgxstore

package
v0.2024.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pgxstore provides an implementation of history.Store backed by a Postgres database. The historical records for all stores are stored in a single table disambiguated via the source parameter.

Index

Constants

View Source
const LargeMaxCount = 1e7

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, source, connStr string, opts ...Option) (history.Store, error)

func NewStoreFromPool

func NewStoreFromPool(source string, pool *pgxpool.Pool, opts ...Option) history.Store

func SetupDB

func SetupDB(ctx context.Context, pool *pgxpool.Pool) error

func SetupStoreFromPool

func SetupStoreFromPool(ctx context.Context, source string, pool *pgxpool.Pool, opts ...Option) (history.Store, error)

Types

type Option

type Option func(*Store)

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger is an option to set the logger used by the store.

func WithMaxAge

func WithMaxAge(maxAge time.Duration) Option

WithMaxAge is an option to set the maximum age of records in the store.

func WithMaxCount

func WithMaxCount(maxCount int64) Option

WithMaxCount is an option to set the maximum number of records in the store.

type Store

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

func (*Store) Append

func (s *Store) Append(ctx context.Context, payload []byte) (history.Record, error)

func (Store) Len

func (s Store) Len(ctx context.Context) (int, error)

func (Store) Read

func (s Store) Read(ctx context.Context, into []history.Record) (int, error)

func (Store) Slice

func (s Store) Slice(from, to history.Record) history.Slice

Jump to

Keyboard shortcuts

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