sqlite

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sqlite provides a SQLite3 database utils.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compact added in v0.4.0

func Compact(ctx context.Context, db *sql.DB) error

func Open

func Open(file string, opts ...OpOption) (*sql.DB, error)

Helper function to open a SQLite3 database.

func OpenTestDB added in v0.3.8

func OpenTestDB(t *testing.T) (*sql.DB, *sql.DB, func())

func ReadDBSize added in v0.4.0

func ReadDBSize(ctx context.Context, db *sql.DB) (uint64, error)

func RecordDelete added in v0.4.0

func RecordDelete(tookSeconds float64)

func RecordInsertUpdate added in v0.4.0

func RecordInsertUpdate(tookSeconds float64)

func RecordSelect added in v0.4.0

func RecordSelect(tookSeconds float64)

func Register added in v0.4.0

func Register(reg *prometheus.Registry) error

Types

type Metrics added in v0.4.0

type Metrics struct {
	Time time.Time

	// The total number of inserts and updates in cumulative count.
	InsertUpdateTotal        int64
	InsertUpdateSecondsTotal float64
	InsertUpdateSecondsAvg   float64

	// The total number of deletes in cumulative count.
	DeleteTotal        int64
	DeleteSecondsTotal float64
	DeleteSecondsAvg   float64

	// The total number of selects in cumulative count.
	SelectTotal        int64
	SelectSecondsTotal float64
	SelectSecondsAvg   float64
}

func ReadMetrics added in v0.4.0

func ReadMetrics(gatherer prometheus.Gatherer) (Metrics, error)

func (Metrics) IsZero added in v0.4.0

func (m Metrics) IsZero() bool

func (Metrics) QPS added in v0.4.0

func (prev Metrics) QPS(cur Metrics) (insertUpdateAvgQPS float64, deleteAvgQPS float64, selectAvgQPS float64)

Computes the QPS for insert/updates, deletes, and selects, based on the previous and current metrics time.

type Op added in v0.3.8

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

type OpOption added in v0.3.8

type OpOption func(*Op)

Jump to

Keyboard shortcuts

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