persistence

package
v0.110.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCursor = errors.New("invalid cursor")

Functions

func Clean added in v0.96.4

func Clean(db *sql.DB, tableName string) error

func CreateTable

func CreateTable(db *sql.DB, tableName string) error

CreateTable creates the table that will persist the peers

Types

type DBOption added in v0.106.1

type DBOption func(*DBStore) error

DBOption is an optional setting that can be used to configure the DBStore

func WithDB added in v0.106.1

func WithDB(db *sql.DB) DBOption

WithDB is a DBOption that lets you use any custom *sql.DB with a DBStore.

func WithRetentionPolicy added in v0.106.1

func WithRetentionPolicy(maxMessages int, maxDuration time.Duration) DBOption

WithRetentionPolicy is a DBOption that specifies the max number of messages to be stored and duration before they're removed from the message store

type DBStore added in v0.106.1

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

DBStore is a MessageProvider that has a *sql.DB connection

func NewDBStore added in v0.106.1

func NewDBStore(log *zap.Logger, options ...DBOption) (*DBStore, error)

Creates a new DB store using the db specified via options. It will create a messages table if it does not exist and clean up records according to the retention policy used

func (*DBStore) Count added in v0.106.1

func (d *DBStore) Count() (int, error)

Count returns the number of rows in the message table

func (*DBStore) GetAll added in v0.106.1

func (d *DBStore) GetAll() ([]gowakuPersistence.StoredMessage, error)

GetAll returns all the stored WakuMessages

func (*DBStore) GetStoredMessage added in v0.106.1

func (d *DBStore) GetStoredMessage(row *sql.Rows) (gowakuPersistence.StoredMessage, error)

GetStoredMessage is a helper function used to convert a `*sql.Rows` into a `StoredMessage`

func (*DBStore) MostRecentTimestamp added in v0.106.1

func (d *DBStore) MostRecentTimestamp() (int64, error)

MostRecentTimestamp returns an unix timestamp with the most recent senderTimestamp in the message table

func (*DBStore) Put added in v0.106.1

func (d *DBStore) Put(env *protocol.Envelope) error

Put inserts a WakuMessage into the DB

func (*DBStore) Query added in v0.106.1

Query retrieves messages from the DB

func (*DBStore) Stop added in v0.106.1

func (d *DBStore) Stop()

Stop closes a DB connection

type Queries

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

Queries are the sqlite queries for a given table.

func NewQueries

func NewQueries(tbl string, db *sql.DB) (*Queries, error)

NewQueries creates a new set of queries for the passed table

func (Queries) Delete

func (q Queries) Delete() string

Delete returns the query for deleting a row.

func (Queries) Exists

func (q Queries) Exists() string

Exists returns the query for determining if a row exists.

func (Queries) Get

func (q Queries) Get() string

Get returns the query for getting a row.

func (Queries) GetSize

func (q Queries) GetSize() string

GetSize returns the query for determining the size of a value.

func (Queries) Limit

func (q Queries) Limit() string

Limit returns the query fragment for limiting results.

func (Queries) Offset

func (q Queries) Offset() string

Offset returns the query fragment for returning rows from a given offset.

func (Queries) Prefix

func (q Queries) Prefix() string

Prefix returns the query fragment for getting a rows with a key prefix.

func (Queries) Put

func (q Queries) Put() string

Put returns the query for putting a row.

func (Queries) Query

func (q Queries) Query() string

Query returns the query for getting multiple rows.

Jump to

Keyboard shortcuts

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