mount

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 46 Imported by: 1

Documentation

Overview

Package mount loads database manifests and opens the corresponding DALgo drivers, producing ready-to-serve core.Database instances. Storage access inside ovdb is dalgo-native: each engine is simply a dal.DB driver plus a schema-mode capability declaration.

Index

Constants

View Source
const (
	// DefaultNativePostgresStatementTimeout is the statement_timeout a native
	// read-only PostgreSQL session starts with when Options sets none.
	DefaultNativePostgresStatementTimeout = 15 * time.Second
	// DefaultNativePostgresDiscoveryTimeout bounds the catalogue read of a native
	// read-only PostgreSQL mount when Options sets none.
	DefaultNativePostgresDiscoveryTimeout = 30 * time.Second
)

Defaults of the native read-only PostgreSQL mount Options.

View Source
const DefaultMountConcurrency = 4

DefaultMountConcurrency is how many manifests All mounts at once.

View Source
const InsecureNativePostgresTransportEnv = "OVDB_NATIVE_POSTGRES_INSECURE_TRANSPORT"

InsecureNativePostgresTransportEnv, set to true, lets every native read-only PostgreSQL mount of the process reach a remote server without a verified TLS connection, as storage.postgres.insecure_transport does for one manifest. It is how a command-line tool that mounts manifests as they are reaches a local proxy or a development server on another host.

Variables

View Source
var ErrMountSkipped = errors.New("not mounted: a required mount failed first")

ErrMountSkipped is the Health error of a spec that was not attempted because a required spec had already failed.

View Source
var ErrNativePostgresDiscoveryTimeout = errors.New("native PostgreSQL discovery did not finish in time")

ErrNativePostgresDiscoveryTimeout is wrapped by the error of a native read-only PostgreSQL mount whose catalogue read (discovery and the read-only role check) did not finish within Options.NativePostgresDiscoveryTimeout. The error also wraps context.DeadlineExceeded.

Functions

func Dir

func Dir(dir string) (map[string]*core.Database, error)

Dir mounts every *.yaml / *.yml manifest found directly in dir, keyed by database id. It fails on the first manifest that does not mount; see DirReport for a scan that tolerates broken manifests.

func DirReport added in v0.6.0

func DirReport(dir string) (map[string]*core.Database, map[string]error, error)

DirReport mounts every *.yaml / *.yml manifest found directly in dir, like Dir, but one manifest that fails to mount does not stop the others. It returns the mounted databases keyed by database id and the failures keyed by manifest path. The error result is non-nil only when dir itself cannot be read.

func DirReportWithOptions added in v0.6.0

func DirReportWithOptions(dir string, opts Options) (map[string]*core.Database, map[string]error, error)

DirReportWithOptions is DirReport mounting each manifest with FileWithOptions, e.g. so a registry scan never writes into user storage. Catalogues in Options.CatalogueDir are per database id and cannot collide (duplicate ids are rejected).

func File

func File(manifestPath string) (*core.Database, error)

File mounts one database from a manifest file. Relative storage paths are resolved against the manifest file's directory.

func FileWithOptions added in v0.6.0

func FileWithOptions(manifestPath string, opts Options) (*core.Database, error)

FileWithOptions is File with mount Options. With CatalogueDir set outside the storage and SkipGitIdentity true, mounting an existing local inGitDB folder or SQLite file adds or changes nothing in it (writes made later through the database still land in the storage, as they must).

Types

type AllOptions added in v0.25.2

type AllOptions struct {
	// Concurrency is how many manifests are mounted at once; zero or less is
	// DefaultMountConcurrency.
	Concurrency int
}

AllOptions tunes AllWithOptions. The zero value is the behaviour of All.

type Health added in v0.25.2

type Health struct {
	Path     string
	ID       string // the database ID, when mounted
	Mounted  bool
	Optional bool
	Err      error // why the mount failed or was not attempted; nil when mounted
	Elapsed  time.Duration
}

Health is the outcome of mounting one Spec.

func All added in v0.25.2

func All(specs []Spec) (map[string]*core.Database, []Health, error)

All mounts every spec with FileWithOptions, DefaultMountConcurrency at a time, and reports the health of each, in the order of specs. A database ID mounted twice fails the later spec, and a mount that panics fails its spec. When a required spec fails, the specs not yet started are skipped (ErrMountSkipped), every database mounted is closed, and the error names the first required failure; the health of every spec is still returned. Otherwise the error is nil and the map holds the databases mounted, keyed by ID.

func AllWithOptions added in v0.25.2

func AllWithOptions(specs []Spec, opts AllOptions) (map[string]*core.Database, []Health, error)

AllWithOptions is All with options.

type Options added in v0.6.0

type Options struct {
	// CatalogueDir, when set, is where the inferred-schema catalogue lives,
	// as <CatalogueDir>/<database id>.inferred.json, for every engine —
	// instead of the default next to (or inside) the user's storage
	// (<file>.inferred.json, <folder>/.ovdb/inferred-schema.json).
	CatalogueDir string
	// SkipGitIdentity disables stamping a repo-local git identity on a local
	// inGitDB repository (see ensureGitIdentity; it only ever acts on a
	// repository top level that has no resolvable identity), so mounting
	// leaves .git/config untouched. Commits then rely on the host's own git
	// identity.
	SkipGitIdentity bool

	// ExcludedNativePostgresRelations omits exact schema/relation pairs from a
	// native read-only PostgreSQL mount's discovered schema. The default is to
	// expose every SELECT-readable relation. This is an opt-in consumer boundary:
	// excluded relations are absent from both discovery and the core's physical
	// collection mapping, so a caller cannot recover them by guessing an encoded
	// collection ID. A non-empty list is rejected for non-PostgreSQL engines and
	// non-native PostgreSQL mounts.
	ExcludedNativePostgresRelations []schema.NativeCollectionSource

	// AllowInsecureNativePostgresTransport lets a native read-only PostgreSQL
	// mount reach a remote host without a verified TLS connection (see
	// docs/native-postgres-read.md). By default such a mount requires
	// sslmode=verify-full or sslmode=verify-ca, with no plaintext fallback, unless
	// every host is local (a Unix socket, a loopback address or localhost). The
	// manifest field storage.postgres.insecure_transport and the environment
	// variable OVDB_NATIVE_POSTGRES_INSECURE_TRANSPORT allow the same.
	AllowInsecureNativePostgresTransport bool

	// NativePostgresStatementTimeout is the statement_timeout a native read-only
	// PostgreSQL session starts with, so the server itself ends a statement that
	// runs too long. Zero is DefaultNativePostgresStatementTimeout (15s).
	NativePostgresStatementTimeout time.Duration

	// NativePostgresDiscoveryTimeout bounds the catalogue read of a native
	// read-only PostgreSQL mount. Zero is DefaultNativePostgresDiscoveryTimeout
	// (30s).
	NativePostgresDiscoveryTimeout time.Duration

	// RequireReadOnlyNativePostgresRole refuses to mount a native read-only
	// PostgreSQL database whose role is a superuser, or owns or may write
	// (INSERT, UPDATE, DELETE or TRUNCATE, on a table or any of its columns) any
	// relation the mount exposes. Off by default; a service that exposes a
	// database to the public, such as the demo datasets, turns it on.
	RequireReadOnlyNativePostgresRole bool
}

Options tunes how FileWithOptions mounts a database. The zero value is the behaviour of File.

type Spec added in v0.25.2

type Spec struct {
	// Path is the manifest file.
	Path string
	// Options are the mount options of this manifest.
	Options Options
	// Optional lets the other mounts go on when this one fails, for example a
	// PostgreSQL database whose catalogue read fails or is slow while the SQLite
	// databases beside it can be served: the failure is reported in its Health and
	// All does not fail because of it. A required mount (the zero value) that
	// fails fails All.
	Optional bool
}

Spec is one manifest All mounts.

Jump to

Keyboard shortcuts

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