sqlite

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SchemaVersion is the version of the SQLite schema understood by this backend.
	// Whenever changes to the schema are made, this version number should be increased
	// to prevent data corruption between incompatible database schemas.
	SchemaVersion = 1
	// Schema is the SQLite database layout.
	Schema = `` /* 379-byte string literal not displayed */

	BeaconsTable = "Beacons"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

func New

func New(path string, ia addr.IA) (*Backend, error)

New returns a new SQLite backend opening a database at the given path. If no database exists a new database is be created. If the schema version of the stored database is different from the one in schema.go, an error is returned.

func (Backend) BeaconSources

func (e Backend) BeaconSources(ctx context.Context) ([]addr.IA, error)

func (Backend) CandidateBeacons

func (e Backend) CandidateBeacons(
	ctx context.Context,
	setSize int,
	usage beacon.Usage,
	src addr.IA,
) ([]beacon.Beacon, error)

func (*Backend) Close

func (b *Backend) Close() error

Close closes the database.

func (Backend) DeleteExpiredBeacons

func (e Backend) DeleteExpiredBeacons(ctx context.Context, now time.Time) (int, error)

func (Backend) GetBeacons

func (e Backend) GetBeacons(
	ctx context.Context,
	params *storagebeacon.QueryParams,
) ([]storagebeacon.Beacon, error)

func (Backend) InsertBeacon

func (e Backend) InsertBeacon(
	ctx context.Context,
	b beacon.Beacon,
	usage beacon.Usage,
) (beacon.InsertStats, error)

InsertBeacon inserts the beacon if it is new or updates the changed information.

func (*Backend) SetMaxIdleConns

func (b *Backend) SetMaxIdleConns(maxIdleConns int)

SetMaxIdleConns sets the maximum number of idle connections.

func (*Backend) SetMaxOpenConns

func (b *Backend) SetMaxOpenConns(maxOpenConns int)

SetMaxOpenConns sets the maximum number of open connections.

Jump to

Keyboard shortcuts

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