sqliteStorage

package
v1.25.1-0...-b751934 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSchema

func InitSchema(conn conn, pageSize int, triggers bool) error

func NewPiecesStorage

func NewPiecesStorage(opts NewPiecesStorageOpts) (_ storage.ClientImplCloser, err error)

A convenience function that creates a connection pool, resource provider, and a pieces storage ClientImpl and returns them all with a Close attached.

func NewPool

func NewPool(opts NewPoolOpts) (_ ConnPool, _ ProviderOpts, err error)

func NewProvider

func NewProvider(pool ConnPool, opts ProviderOpts) (_ *provider, err error)

Needs the ConnPool size so it can initialize all the connections with pragmas. Takes ownership of the ConnPool (since it has to initialize all the connections anyway).

func SetCapacity

func SetCapacity(conn conn, cap int64) error

Set the capacity limit to exactly this value.

func UnlimitCapacity

func UnlimitCapacity(conn conn) error

Remove any capacity limits.

Types

type ConnPool

type ConnPool interface {
	Get(context.Context) conn
	Put(conn)
	Close() error
}

type NewPiecesStorageOpts

type NewPiecesStorageOpts struct {
	NewPoolOpts
	ProvOpts    func(*ProviderOpts)
	StorageOpts func(*storage.ResourcePiecesOpts)
}

type NewPoolOpts

type NewPoolOpts struct {
	// See https://www.sqlite.org/c3ref/open.html. NB: "If the filename is an empty string, then a
	// private, temporary on-disk database will be created. This private database will be
	// automatically deleted as soon as the database connection is closed."
	Path     string
	Memory   bool
	NumConns int
	// Forces WAL, disables shared caching.
	NoConcurrentBlobReads bool
	DontInitSchema        bool
	PageSize              int
	// If non-zero, overrides the existing setting.
	Capacity int64
}

type ProviderOpts

type ProviderOpts struct {
	NumConns int
	// Concurrent blob reads require WAL.
	NoConcurrentBlobReads bool
	BatchWrites           bool
	MmapSize              int64
	MmapSizeOk            bool
}

There's some overlap here with NewPoolOpts, and I haven't decided what needs to be done. For now, the fact that the pool opts are a superset, means our helper NewPiecesStorage can just take the top-level option type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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