snapstore

package
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithIDGenerator

func WithIDGenerator(fn func() (string, error)) func(*Client)

Types

type Client

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

func New

func New(db *pgxpool.Pool, stores []string, opts ...func(*Client)) *Client

func (*Client) Store

func (c *Client) Store(name string) *Store

func (*Client) Tx

func (c *Client) Tx(ctx context.Context, fn func(Options) error) error

type Conflict

type Conflict struct {
}

func (*Conflict) Error

func (e *Conflict) Error() string

type Cursor

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

func (*Cursor) Close

func (c *Cursor) Close()

func (*Cursor) Err

func (c *Cursor) Err() error

func (*Cursor) HasNext

func (c *Cursor) HasNext() bool

func (*Cursor) Next

func (c *Cursor) Next() (*Snapshot, error)

type DB

type DB interface {
	Begin(context.Context) (pgx.Tx, error)
	Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
	QueryRow(context.Context, string, ...any) pgx.Row
	Query(context.Context, string, ...any) (pgx.Rows, error)
}

type Options

type Options struct {
	Context     context.Context
	Transaction *Transaction
}

type Snapshot

type Snapshot struct {
	SnapshotID string
	ID         string
	Data       json.RawMessage
	DateFrom   *time.Time
	DateUntil  *time.Time
}

func (*Snapshot) Scan

func (s *Snapshot) Scan(data any) error

type Store

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

func (*Store) Add

func (s *Store) Add(id string, data any, o Options) error

func (*Store) AddAfter

func (s *Store) AddAfter(snapshotID, id string, data any, o Options) (string, error)

func (*Store) CountSql

func (s *Store) CountSql(sql string, values []any, o Options) (int, error)

func (*Store) GetAll

func (s *Store) GetAll(o Options) (*Cursor, error)

func (*Store) GetAllSnapshots

func (s *Store) GetAllSnapshots(o Options) (*Cursor, error)

func (*Store) GetByID

func (s *Store) GetByID(ids []string, o Options) (*Cursor, error)

func (*Store) GetCurrentSnapshot

func (s *Store) GetCurrentSnapshot(id string, o Options) (*Snapshot, error)

func (*Store) GetHistory

func (s *Store) GetHistory(id string, o Options) (*Cursor, error)

func (*Store) GetSnapshotBefore added in v1.0.42

func (s *Store) GetSnapshotBefore(id string, dateFrom time.Time, o Options) (*Snapshot, error)

func (*Store) ImportSnapshot

func (store *Store) ImportSnapshot(snapshot *Snapshot, options Options) error

func (*Store) Name

func (s *Store) Name() string

func (*Store) Purge

func (s *Store) Purge(id string, o Options) error

func (*Store) PurgeAll

func (s *Store) PurgeAll(o Options) error

func (*Store) Select

func (s *Store) Select(sql string, values []any, options Options) (*Cursor, error)

func (*Store) Update

func (s *Store) Update(snapshotID, id string, data any, o Options) (*Snapshot, error)

type Transaction

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

Jump to

Keyboard shortcuts

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