pgdb

package
v1.5.11 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store represents access to the postgres database for beacon management.

func NewStore

func NewStore(ctx context.Context, l log.Logger, db *sqlx.DB, beaconName string) (*Store, error)

NewStore returns a new store that provides the CRUD based API needed for supporting drand serialization.

func (*Store) AddBeaconID

func (p *Store) AddBeaconID(ctx context.Context, beaconName string) (int, error)

AddBeaconID adds the beacon to the database if it does not exist.

func (*Store) AddFK

func (p *Store) AddFK(ctx context.Context) error

AddFK reconstructs the relation between beacons and beacon_details tables after Store.DropFK was called.

func (*Store) BatchPut

func (p *Store) BatchPut(ctx context.Context, bs []chain.Beacon) error

BatchPut is useful if you want to write a lot of beacons to the database at once.

func (*Store) Close

func (p *Store) Close(context.Context) error

Close is an noop.

func (*Store) Cursor

func (p *Store) Cursor(ctx context.Context, fn func(context.Context, chain.Cursor) error) error

Cursor returns a cursor for iterating over the beacon table.

func (*Store) Del

func (p *Store) Del(ctx context.Context, round uint64) error

Del removes the specified round from the beacon table.

func (*Store) DropFK

func (p *Store) DropFK(ctx context.Context) error

DropFK is used to optimize the calls to Store.BatchPut and should be called before it. It drops the relation between beacons and beacon_details tables.

func (*Store) Get

func (p *Store) Get(ctx context.Context, round uint64) (*chain.Beacon, error)

Get returns the specified beacon from the configured beacon table.

func (*Store) Last

func (p *Store) Last(ctx context.Context) (*chain.Beacon, error)

Last returns the last beacon stored in the configured beacon table.

func (*Store) Len

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

Len returns the number of beacons in the configured beacon table.

func (*Store) Put

func (p *Store) Put(ctx context.Context, b *chain.Beacon) error

Put adds the specified beacon to the database.

func (*Store) SaveTo

func (p *Store) SaveTo(context.Context, io.Writer) error

SaveTo does something and I am not sure just yet.

Jump to

Keyboard shortcuts

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