internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: GPL-2.0 Imports: 12 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

View Source
var (
	LibExecDir = "/usr/libexec"
	SysConfDir = "/etc"
)

These variables exist to allow overwriting the paths using `go build -ldflags "-X ...", see Makefile.

View Source
var ErrSchemaNotExists = errors.New("no database schema exists")

ErrSchemaNotExists indicates that no Icinga Notifications database schema has been imported yet.

View Source
var Version = version.Version("1.0.0", "$Format:%(describe)$", "$Format:%H$")

Version contains version and Git commit information.

The placeholders are replaced on `git archive` using the `export-subst` attribute.

Functions

func AcquireSchemaLock added in v1.0.0

func AcquireSchemaLock(ctx context.Context, db *database.DB) error

AcquireSchemaLock acquires a named lock/advisory lock for the database schema check and import process.

Please do not pass the main database connection to this function, but a dedicated one with a maximum of 1 open connection, as the lock will be held until the connection is closed. This prevents other processes from acquiring the lock while the schema import/check is in progress.

func CheckSchema added in v1.0.0

func CheckSchema(ctx context.Context, db *database.DB) error

CheckSchema verifies that the database schema version matches the expected version for the database driver.

Make sure to call AcquireSchemaLock() before calling this function to prevent concurrent schema imports.

func ImportSchema added in v1.0.0

func ImportSchema(ctx context.Context, db *database.DB, schemaDir string) error

ImportSchema imports the initial database schema from schemaDir.

It reads the schema.sql file for the database driver from schemaDir/mysql or schemaDir/pgsql and runs its statements (for PostgreSQL in a single tx). On PostgreSQL, a failed import is fully rolled back. On MySQL, DDL statements commit implicitly, so a failed import may leave a partially created schema behind.

Make sure to call AcquireSchemaLock() before calling this function to prevent concurrent schema imports.

Types

This section is empty.

Jump to

Keyboard shortcuts

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