pool

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package pool provides access to SQLite database 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 database connections.

func New

func New(u string, l *zap.Logger) (*Pool, error)

New creates a pool for SQLite databases in the given directory.

func (*Pool) Close

func (p *Pool) Close()

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

func (*Pool) Drop

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

Drop closes and removes a database by 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) *sql.DB

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

func (*Pool) GetOrCreate

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

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

Returned boolean value indicates whether the connection 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