store

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store is a plugin's own SQLite database, in the state directory the host gives it at start: opened with the plugin's migrations, and filled once from the import.db the host's store migration exported for it. The host never reads it.

Index

Constants

View Source
const (
	// File is the store's name in the plugin's state directory.
	File = "plugin.db"
	// ImportFile is what the host's store migration exported for the plugin.
	ImportFile = "import.db"
	// Imported is ImportFile once imported.
	Imported = "import.db.done"
	// ImportSchema is the schema ImportFile is attached as while Import runs.
	ImportSchema = "import"
)

Variables

This section is empty.

Functions

func Open

func Open(ctx context.Context, dir string, opts Options) (*sql.DB, error)

Open opens dir's store, applies the migrations it lacks, then imports dir's ImportFile once and renames it Imported. The store records the import in the import's own transaction, so an ImportFile left in place by a crash before the rename is renamed and never imported again. A failed migration or import leaves the store as it was and the file in place.

Types

type Migration

type Migration struct {
	Version int
	Up      func(ctx context.Context, tx *sql.Tx) error
}

Migration moves the store to Version, which counts from 1 without gaps.

type Options

type Options struct {
	Migrations []Migration
	// Import copies what the plugin keeps from ImportSchema's tables, in the
	// transaction that records the import in the store; nil imports nothing.
	Import func(ctx context.Context, tx *sql.Tx) error
}

Options are the plugin's migrations and its import.

Jump to

Keyboard shortcuts

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