pool

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package pool provides access to SQLite databases and their connections.

It should be used only by the metadata package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool provides access to SQLite databases and their connections.

func New

func New(u string, l *zap.Logger, sp *state.Provider) (*Pool, map[string]*fsql.DB, error)

New creates a pool for SQLite databases in the directory specified by SQLite URI.

All databases are opened on creation.

The returned map is the initial set of existing databases. It should not be modified.

func (*Pool) Close

func (p *Pool) Close()

Close closes all databases in the pool and frees all resources.

func (*Pool) Collect added in v1.7.0

func (p *Pool) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Pool) Describe added in v1.7.0

func (p *Pool) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Pool) Drop

func (p *Pool) Drop(ctx context.Context, name string) bool

Drop closes and removes a database by valid name.

It does nothing if the database does not exist.

Returned boolean value indicates whether the database was removed.

func (*Pool) GetExisting

func (p *Pool) GetExisting(ctx context.Context, name string) *fsql.DB

GetExisting returns an existing database by valid name, or nil.

func (*Pool) GetOrCreate

func (p *Pool) GetOrCreate(ctx context.Context, name string) (*fsql.DB, bool, error)

GetOrCreate returns an existing database by valid name, or creates a new one.

Returned boolean value indicates whether the database was created.

func (*Pool) List

func (p *Pool) List(ctx context.Context) []string

List returns a sorted list of database names in the pool.

Jump to

Keyboard shortcuts

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