sqlite

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: Apache-2.0 Imports: 18 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 = `` /* 2141-byte string literal not displayed */

)

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) (*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) BeginTransaction

func (b *Backend) BeginTransaction(ctx context.Context, opts *sql.TxOptions) (
	backend.Transaction, error)

BeginTransaction begins a transaction on the database.

func (*Backend) Close

func (b *Backend) Close() error

Close closes the databse.

func (Backend) DeleteExpiredIndices

func (x Backend) DeleteExpiredIndices(ctx context.Context, now time.Time) (int, error)

DeleteExpiredIndices will remove expired indices from the DB. If a reservation is left without any index after removing the expired ones, it will also be removed. This applies to both segment and e2e reservations.

func (Backend) DeleteSegmentRsv

func (x Backend) DeleteSegmentRsv(ctx context.Context, ID *reservation.SegmentID) error

DeleteSegmentRsv removes the segment reservation

func (Backend) GetAllSegmentRsvs

func (x Backend) GetAllSegmentRsvs(ctx context.Context) ([]*segment.Reservation, error)

GetAllSegmentRsvs returns all segment reservations.

func (Backend) GetE2ERsvFromID

func (x Backend) GetE2ERsvFromID(ctx context.Context, ID *reservation.E2EID) (
	*e2e.Reservation, error)

GetE2ERsvFromID finds the end to end resevation given its ID.

func (Backend) GetE2ERsvsOnSegRsv

func (x Backend) GetE2ERsvsOnSegRsv(ctx context.Context, ID *reservation.SegmentID) (
	[]*e2e.Reservation, error)

GetE2ERsvsOnSegRsv returns the e2e reservations running on top of a given segment one.

func (Backend) GetSegmentRsvFromID

func (x Backend) GetSegmentRsvFromID(ctx context.Context, ID *reservation.SegmentID) (
	*segment.Reservation, error)

func (Backend) GetSegmentRsvFromPath

func (x Backend) GetSegmentRsvFromPath(ctx context.Context,
	path segment.ReservationTransparentPath) (*segment.Reservation, error)

GetSegmentRsvFromPath searches for a segment reservation with the specified path.

func (Backend) GetSegmentRsvsFromIFPair

func (x Backend) GetSegmentRsvsFromIFPair(ctx context.Context, ingress, egress *uint16) (
	[]*segment.Reservation, error)

GetSegmentRsvsFromIFPair returns all segment reservations that enter this AS at the specified ingress and exit at that egress.

func (Backend) GetSegmentRsvsFromSrcDstIA

func (x Backend) GetSegmentRsvsFromSrcDstIA(ctx context.Context, srcIA, dstIA addr.IA) (
	[]*segment.Reservation, error)

GetSegmentRsvsFromSrcDstIA returns all reservations that start at src AS and end in dst AS.

func (Backend) NewSegmentRsv

func (x Backend) NewSegmentRsv(ctx context.Context, rsv *segment.Reservation) error

NewSegmentRsv creates a new segment reservation in the DB, with an unused reservation ID. The reservation must contain at least one index. The created ID is set in the reservation pointer argument.

func (Backend) PersistE2ERsv

func (x Backend) PersistE2ERsv(ctx context.Context, rsv *e2e.Reservation) error

func (Backend) PersistSegmentRsv

func (x Backend) PersistSegmentRsv(ctx context.Context, rsv *segment.Reservation) error

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