meldbase

package module
v0.1.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 4 Imported by: ? 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.

README

Meldbase

Meldbase is a single-file document database for Go applications. Open a file, write documents, query them, and close it. When a browser or another process needs access, run the optional meld server in front of the same file.

It is an alpha project. It is a good fit for local development and single-node applications; do not use it for data you cannot afford to lose.

Start in two minutes

Install the CLI on macOS:

brew tap crapthings/tap
brew trust --tap crapthings/tap
brew install crapthings/tap/meldbase

Start a local database and HTTP server:

mkdir -p ./data
meld serve --db ./data/app.meld --dev-no-auth

The server listens on http://127.0.0.1:8080. In another terminal, check that it is ready:

curl http://127.0.0.1:8080/readyz

--dev-no-auth is intentionally for local development only. Do not expose that server to a network.

Embed it in Go

For the smallest setup, use the database directly from your Go process:

go get github.com/crapthings/meldbase@latest
package main

import (
	"context"
	"log"

	"github.com/crapthings/meldbase"
)

func main() {
	ctx := context.Background()
	db, err := meldbase.Open("app.meld")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	todos := db.Collection("todos")
	_, err = todos.InsertOne(ctx, meldbase.Document{
		"title": meldbase.String("Ship something"),
		"done":  meldbase.Bool(false),
	})
	if err != nil {
		log.Fatal(err)
	}
}

The app.meld file remains after the process exits. One writable process owns one database file at a time.

Choose a path

If you want to… Start here
Put durable documents in a Go application Five-minute Go tour
Use Meldbase from a browser Run meld serve, then read the Browser guide
Use Meldbase from another Node.js process Run meld serve, then read the Node.js guide

What it is — and is not

Meldbase gives one application a durable document file, typed queries, indexes, and live query updates. It can add an HTTP and WebSocket boundary when needed.

It is not a hosted database, a MongoDB-compatible service, or a distributed system. It does not provide automatic failover, sharding, or built-in user identity.

Next

For project contributors, see CONTRIBUTING.md. Security reports are covered by SECURITY.md.

License

Licensed under the Apache License 2.0.

Documentation

Overview

Package meldbase provides an embedded, durable, realtime document database.

Stability: Alpha. The Go database API can change between alpha releases; operators and applications must follow the release notes and migration instructions when upgrading. Versioned HTTP/WebSocket protocol contracts are documented separately at https://meldbase.com/protocol-stability. HTTP/WebSocket serving is provided by github.com/crapthings/meldbase/server; optional deployment adapters live below github.com/crapthings/meldbase/integrations.

Index

Constants

View Source
const ArrayKind = database.ArrayKind

ArrayKind identifies an array of values.

View Source
const BinaryKind = database.BinaryKind

BinaryKind identifies binary data.

View Source
const BoolKind = database.BoolKind

BoolKind identifies a boolean value.

View Source
const CreateCollectionOperation = database.CreateCollectionOperation

CreateCollectionOperation marks collection creation in the durable database change feed.

Ordinary collection creation remains implicit for CRUD callers.

View Source
const CreateIndexOperation = database.CreateIndexOperation

CreateIndexOperation marks publication of a new index.

View Source
const DefaultCommitCoordinatorMaxBatch = database.DefaultCommitCoordinatorMaxBatch

DefaultCommitCoordinatorMaxBatch sets the default maximum number of writes in a commit group.

View Source
const DefaultCommitCoordinatorMaxDelay = database.DefaultCommitCoordinatorMaxDelay

DefaultCommitCoordinatorMaxDelay sets the default wait for grouping queued writes.

View Source
const DefaultCommitCoordinatorMaxPending = database.DefaultCommitCoordinatorMaxPending

DefaultCommitCoordinatorMaxPending sets the default maximum number of queued writes.

View Source
const DefaultCommitRetentionMaxBytes = database.DefaultCommitRetentionMaxBytes

DefaultCommitRetentionMaxBytes sets the default retained commit payload limit.

View Source
const DefaultCommitRetentionMaxCommits = database.DefaultCommitRetentionMaxCommits

DefaultCommitRetentionMaxCommits sets the default retained commit count limit.

View Source
const DefaultMaxDocumentBytes = database.DefaultMaxDocumentBytes

DefaultMaxDocumentBytes sets the default canonical document byte limit.

View Source
const DefaultMaxFileBytes = database.DefaultMaxFileBytes

DefaultMaxFileBytes sets the default physical database file size limit.

View Source
const DefaultMaxIndexBuildBytes = database.DefaultMaxIndexBuildBytes

DefaultMaxIndexBuildBytes sets the default index-build byte limit.

View Source
const DefaultMaxIndexBuildEntries = database.DefaultMaxIndexBuildEntries

DefaultMaxIndexBuildEntries sets the default index-build entry count limit.

View Source
const DefaultMaxQueryCandidates = database.DefaultMaxQueryCandidates

DefaultMaxQueryCandidates sets the default retained query candidate limit.

View Source
const DefaultMaxQueryDocumentsExamined = database.DefaultMaxQueryDocumentsExamined

DefaultMaxQueryDocumentsExamined sets the default examined document limit per query.

View Source
const DefaultMaxQueryKeysExamined = database.DefaultMaxQueryKeysExamined

DefaultMaxQueryKeysExamined sets the default examined index key limit per query.

View Source
const DefaultMaxQuerySkip = database.DefaultMaxQuerySkip

DefaultMaxQuerySkip sets the default query offset limit.

View Source
const DefaultMaxQuerySortBytes = database.DefaultMaxQuerySortBytes

DefaultMaxQuerySortBytes sets the default retained sort data byte limit.

View Source
const DefaultMaxReactiveViewBytes = database.DefaultMaxReactiveViewBytes

DefaultMaxReactiveViewBytes sets the default retained live query byte limit.

View Source
const DefaultMaxReactiveViewDocuments = database.DefaultMaxReactiveViewDocuments

DefaultMaxReactiveViewDocuments sets the default number of document versions retained by a live query.

Views retain matching versions for incremental ordering and updates, not merely the page currently emitted to a subscriber.

View Source
const DefaultMaxTransactionBytes = database.DefaultMaxTransactionBytes

DefaultMaxTransactionBytes sets the default canonical transaction byte limit.

View Source
const DefaultMaxTransactionChanges = database.DefaultMaxTransactionChanges

DefaultMaxTransactionChanges sets the default transaction change count limit.

View Source
const DefaultReplayDeliveryTimeout = database.DefaultReplayDeliveryTimeout

DefaultReplayDeliveryTimeout limits how long replay waits to deliver into a full buffer.

A delivery timeout releases the retained-history lease.

View Source
const DefaultReplicationMaxFrameBytes = database.DefaultReplicationMaxFrameBytes

DefaultReplicationMaxFrameBytes sets the default replication frame byte limit.

View Source
const DefaultRollbackAnchorOperationTimeout = database.DefaultRollbackAnchorOperationTimeout

DefaultRollbackAnchorOperationTimeout limits how long a rollback anchor operation may delay a commit response.

View Source
const DeleteOperation = database.DeleteOperation

DeleteOperation marks a document deletion.

View Source
const DiagnosticCanceled = database.DiagnosticCanceled

DiagnosticCanceled marks a canceled operation.

View Source
const DiagnosticCommit = database.DiagnosticCommit

DiagnosticCommit marks a commit diagnostic.

View Source
const DiagnosticFailure = database.DiagnosticFailure

DiagnosticFailure marks a failed operation.

View Source
const DiagnosticQuery = database.DiagnosticQuery

DiagnosticQuery marks a query diagnostic.

View Source
const DiagnosticSuccess = database.DiagnosticSuccess

DiagnosticSuccess marks a successful operation.

View Source
const Float64Kind = database.Float64Kind

Float64Kind identifies a 64-bit float.

View Source
const IDKind = database.IDKind

IDKind identifies a document identifier.

View Source
const IndexBuildFailureCanceled = database.IndexBuildFailureCanceled

IndexBuildFailureCanceled marks a canceled index build.

View Source
const IndexBuildFailureHistoryLost = database.IndexBuildFailureHistoryLost

IndexBuildFailureHistoryLost marks a build whose required change history was lost.

View Source
const IndexBuildFailureInvalidIndex = database.IndexBuildFailureInvalidIndex

IndexBuildFailureInvalidIndex marks a build with invalid index data.

View Source
const IndexBuildFailureNone = database.IndexBuildFailureNone

IndexBuildFailureNone marks the absence of an index-build failure.

View Source
const IndexBuildFailureResourceLimit = database.IndexBuildFailureResourceLimit

IndexBuildFailureResourceLimit marks an index build that exceeded a resource limit.

View Source
const IndexBuildFailureUniqueConflict = database.IndexBuildFailureUniqueConflict

IndexBuildFailureUniqueConflict marks a duplicate key found while building a unique index.

View Source
const IndexBuildPhaseCatchUp = database.IndexBuildPhaseCatchUp

IndexBuildPhaseCatchUp marks a build applying changes after its initial snapshot.

View Source
const IndexBuildPhaseFailed = database.IndexBuildPhaseFailed

IndexBuildPhaseFailed marks a build that stopped with a terminal failure.

View Source
const IndexBuildPhaseReady = database.IndexBuildPhaseReady

IndexBuildPhaseReady marks a build ready for publication.

View Source
const IndexBuildPhaseScan = database.IndexBuildPhaseScan

IndexBuildPhaseScan marks a build scanning its initial document snapshot.

View Source
const InsertOperation = database.InsertOperation

InsertOperation marks a document insertion.

View Source
const Int64Kind = database.Int64Kind

Int64Kind identifies a signed 64-bit integer.

View Source
const NullKind = database.NullKind

NullKind identifies a null value.

View Source
const ObjectKind = database.ObjectKind

ObjectKind identifies a document object.

View Source
const PageSize = database.PageSize

PageSize sets the byte size of each storage page.

View Source
const QueryDeltaAdd = database.QueryDeltaAdd

QueryDeltaAdd inserts a document before an anchor.

View Source
const QueryDeltaChange = database.QueryDeltaChange

QueryDeltaChange replaces a document without changing its position.

View Source
const QueryDeltaMove = database.QueryDeltaMove

QueryDeltaMove moves a document before an anchor.

View Source
const QueryDeltaRemove = database.QueryDeltaRemove

QueryDeltaRemove removes a document from an ordered result.

View Source
const RecoveryAutomatic = database.RecoveryAutomatic

RecoveryAutomatic allows bounded automatic recovery when opening a database.

View Source
const RecoveryRequireClean = database.RecoveryRequireClean

RecoveryRequireClean rejects opening a database that needs recovery.

View Source
const ReplaceIndexOperation = database.ReplaceIndexOperation

ReplaceIndexOperation marks replacement of an existing index.

View Source
const ReplicationAckFrame = database.ReplicationAckFrame

ReplicationAckFrame identifies a durable replication acknowledgment.

View Source
const ReplicationBatchFrame = database.ReplicationBatchFrame

ReplicationBatchFrame identifies a replication change-batch frame.

View Source
const ReplicationHelloFrame = database.ReplicationHelloFrame

ReplicationHelloFrame identifies a replication handshake frame.

View Source
const ReplicationProtocolVersion = database.ReplicationProtocolVersion

ReplicationProtocolVersion identifies the protocol for replicating commits between trusted servers.

This version is separate from the browser realtime subscription protocol.

View Source
const ReplicationResyncFrame = database.ReplicationResyncFrame

ReplicationResyncFrame identifies a request to rebuild a replica from a snapshot.

View Source
const StorageFormatCurrent = database.StorageFormatCurrent

StorageFormatCurrent identifies the supported database file format.

View Source
const StorageFormatUnknown = database.StorageFormatUnknown

StorageFormatUnknown identifies a missing or empty database file.

View Source
const StringKind = database.StringKind

StringKind identifies a string.

View Source
const TimeKind = database.TimeKind

TimeKind identifies a timestamp.

View Source
const UpdateOperation = database.UpdateOperation

UpdateOperation marks a document update.

Variables

View Source
var DefaultQueryLimits = database.DefaultQueryLimits

DefaultQueryLimits provides the default query input limits.

View Source
var ErrBackupDestinationExists = database.ErrBackupDestinationExists

ErrBackupDestinationExists reports that the backup destination already exists or is the source.

View Source
var ErrBackupUnsupported = database.ErrBackupUnsupported

ErrBackupUnsupported reports that physical backup requires an open durable database.

View Source
var ErrClosed = database.ErrClosed

ErrClosed reports that the database is closed.

View Source
var ErrCommitOutcomeUnknown = database.ErrCommitOutcomeUnknown

ErrCommitOutcomeUnknown means cancellation or a lost caller connection raced an already-admitted durable write.

Callers must reconcile by the returned document ID(s), rather than retrying business logic blindly.

View Source
var ErrCompactionDestinationExists = database.ErrCompactionDestinationExists

ErrCompactionDestinationExists reports that the compaction destination already exists.

View Source
var ErrCompactionUnsupported = database.ErrCompactionUnsupported

ErrCompactionUnsupported reports that compaction requires an open durable database.

View Source
var ErrCompoundIndexUnsupported = database.ErrCompoundIndexUnsupported

ErrCompoundIndexUnsupported reports that compound or descending indexes are unsupported.

View Source
var ErrCorrupt = database.ErrCorrupt

ErrCorrupt reports database corruption.

View Source
var ErrDatabaseIdentity = database.ErrDatabaseIdentity

ErrDatabaseIdentity reports an unexpected database identity.

View Source
var ErrDatabaseLocked = database.ErrDatabaseLocked

ErrDatabaseLocked reports that the database is locked by another process.

View Source
var ErrDestinationExists = database.ErrDestinationExists

ErrDestinationExists reports that the destination already exists.

View Source
var ErrDiagnosticsActive = database.ErrDiagnosticsActive

ErrDiagnosticsActive reports that a diagnostics session is already active.

View Source
var ErrDuplicateID = database.ErrDuplicateID

ErrDuplicateID reports a duplicate document ID.

View Source
var ErrDuplicateKey = database.ErrDuplicateKey

ErrDuplicateKey reports a duplicate index key.

View Source
var ErrDurability = database.ErrDurability

ErrDurability reports a durability failure that disables writes.

View Source
var ErrDurableConsumerExists = database.ErrDurableConsumerExists

ErrDurableConsumerExists reports that the durable change consumer already exists.

View Source
var ErrDurableConsumerNotFound = database.ErrDurableConsumerNotFound

ErrDurableConsumerNotFound reports that the durable change consumer was not found.

View Source
var ErrDurableConsumerUnsupported = database.ErrDurableConsumerUnsupported

ErrDurableConsumerUnsupported reports that durable change consumers require a durable database.

View Source
var ErrHistoryLost = database.ErrHistoryLost

ErrHistoryLost reports that the requested history is no longer retained.

View Source
var ErrImmutableID = database.ErrImmutableID

ErrImmutableID reports that _id is immutable.

View Source
var ErrIndexBuildExists = database.ErrIndexBuildExists

ErrIndexBuildExists reports that the index build already exists.

View Source
var ErrIndexBuildFailed = database.ErrIndexBuildFailed

ErrIndexBuildFailed reports that the index build is in a terminal failed state.

View Source
var ErrIndexBuildNotFound = database.ErrIndexBuildNotFound

ErrIndexBuildNotFound reports that the index build was not found.

View Source
var ErrIndexBuildSchedulerRunning = database.ErrIndexBuildSchedulerRunning

ErrIndexBuildSchedulerRunning reports that the index build scheduler is already running.

View Source
var ErrIndexBuildUnsupported = database.ErrIndexBuildUnsupported

ErrIndexBuildUnsupported reports that resumable index builds require a durable database.

View Source
var ErrInsecureFileMode = database.ErrInsecureFileMode

ErrInsecureFileMode reports that the database file permissions are not owner-private.

View Source
var ErrInvalidCollection = database.ErrInvalidCollection

ErrInvalidCollection reports an invalid collection name.

View Source
var ErrInvalidCommitCoordinatorOptions = database.ErrInvalidCommitCoordinatorOptions

ErrInvalidCommitCoordinatorOptions reports invalid commit coordinator options.

View Source
var ErrInvalidDelta = database.ErrInvalidDelta

ErrInvalidDelta reports an invalid query delta.

View Source
var ErrInvalidDocument = database.ErrInvalidDocument

ErrInvalidDocument reports an invalid document.

View Source
var ErrInvalidFilter = database.ErrInvalidFilter

ErrInvalidFilter reports an invalid filter.

View Source
var ErrInvalidIndex = database.ErrInvalidIndex

ErrInvalidIndex reports an invalid index definition.

View Source
var ErrInvalidIndexBuildSchedulerOptions = database.ErrInvalidIndexBuildSchedulerOptions

ErrInvalidIndexBuildSchedulerOptions reports invalid index build scheduler options.

View Source
var ErrInvalidReclamationOptions = database.ErrInvalidReclamationOptions

ErrInvalidReclamationOptions reports invalid reclamation options.

View Source
var ErrInvalidReplayDeliveryTimeout = database.ErrInvalidReplayDeliveryTimeout

ErrInvalidReplayDeliveryTimeout reports invalid replay delivery timeout.

View Source
var ErrInvalidResourceLimits = database.ErrInvalidResourceLimits

ErrInvalidResourceLimits reports invalid resource limits.

View Source
var ErrInvalidRollbackProtection = database.ErrInvalidRollbackProtection

ErrInvalidRollbackProtection reports invalid rollback protection options.

View Source
var ErrInvalidUpdate = database.ErrInvalidUpdate

ErrInvalidUpdate reports an invalid update.

View Source
var ErrLogicalArchiveDestinationExists = database.ErrLogicalArchiveDestinationExists

ErrLogicalArchiveDestinationExists reports that the logical archive destination already exists or is the source.

View Source
var ErrLogicalArchiveUnsupported = database.ErrLogicalArchiveUnsupported

ErrLogicalArchiveUnsupported reports that logical archive requires an open durable database.

View Source
var ErrMutationLimit = database.ErrMutationLimit

ErrMutationLimit reports that a mutation exceeded its affected-row limit.

View Source
var ErrNotFound = database.ErrNotFound

ErrNotFound reports that the document was not found.

View Source
var ErrPrimaryWriteFence = database.ErrPrimaryWriteFence

ErrPrimaryWriteFence reports that the primary write fence rejected the commit.

View Source
var ErrQueryBudget = database.ErrQueryBudget

ErrQueryBudget reports that one query exceeded an execution-work budget.

Callers can use errors.Is to distinguish this from invalid query input.

View Source
var ErrReclamationConflict = database.ErrReclamationConflict

ErrReclamationConflict reports that the online reclamation conflicted with concurrent writes.

View Source
var ErrReclamationUnsupported = database.ErrReclamationUnsupported

ErrReclamationUnsupported reports that page reclamation requires an open durable database.

View Source
var ErrRecoveryRequired = database.ErrRecoveryRequired

ErrRecoveryRequired reports that the selected policy requires startup recovery.

View Source
var ErrReplicaPromoted = database.ErrReplicaPromoted

ErrReplicaPromoted reports that the follower has been promoted and no longer accepts replication.

View Source
var ErrReplicaPromotionAuthority = database.ErrReplicaPromotionAuthority

ErrReplicaPromotionAuthority reports that the follower promotion requires an external fencing authority.

View Source
var ErrReplicaPromotionFence = database.ErrReplicaPromotionFence

ErrReplicaPromotionFence reports that the follower promotion fence does not match local state.

View Source
var ErrReplicaPromotionWriteFence = database.ErrReplicaPromotionWriteFence

ErrReplicaPromotionWriteFence reports that the follower promotion requires a configured primary write fence.

View Source
var ErrReplicaProtocol = database.ErrReplicaProtocol

ErrReplicaProtocol reports an invalid replication protocol frame.

View Source
var ErrReplicaReadOnly = database.ErrReplicaReadOnly

ErrReplicaReadOnly reports that the follower is read-only.

View Source
var ErrReplicaSequence = database.ErrReplicaSequence

ErrReplicaSequence reports that the follower change token is not the next sequence.

View Source
var ErrReplicaSourceActive = database.ErrReplicaSourceActive

ErrReplicaSourceActive reports that the replication source consumer already has an active session.

View Source
var ErrResourceLimit = database.ErrResourceLimit

ErrResourceLimit reports that an operation exceeded a resource limit.

View Source
var ErrRollbackAnchor = database.ErrRollbackAnchor

ErrRollbackAnchor reports a failure to persist the rollback anchor.

View Source
var ErrRollbackAnchorRequired = database.ErrRollbackAnchorRequired

ErrRollbackAnchorRequired reports that the rollback anchor is missing; explicit initialization is required.

View Source
var ErrRollbackDetected = database.ErrRollbackDetected

ErrRollbackDetected reports that the database was rolled back.

View Source
var ErrSlowConsumer = database.ErrSlowConsumer

ErrSlowConsumer reports that the change consumer is too slow.

View Source
var ErrUnsupportedFormat = database.ErrUnsupportedFormat

ErrUnsupportedFormat reports an unsupported storage format or required feature.

View Source
var ErrVerificationUnsupported = database.ErrVerificationUnsupported

ErrVerificationUnsupported reports that verification requires an existing database.

View Source
var ErrWriteConflict = database.ErrWriteConflict

ErrWriteConflict reports that the write transaction snapshot conflicted.

View Source
var ErrWriteTransactionUnsupported = database.ErrWriteTransactionUnsupported

ErrWriteTransactionUnsupported reports that write transactions require a durable database.

Functions

func MarshalQuerySpecJSON

func MarshalQuerySpecJSON(query QuerySpec) ([]byte, error)

MarshalQuerySpecJSON validates a query and encodes its canonical JSON representation.

The encoded query is used for transport fingerprints and cross-language conformance.

func MarshalReplicationFrame

func MarshalReplicationFrame(frame ReplicationFrame, limits ReplicationFrameLimits) ([]byte, error)

MarshalReplicationFrame validates and encodes a replication message as bounded JSON.

Document images use base64 of the storage-independent typed document codec. It is suitable for WebSocket binary/text messages, QUIC streams or framed RPC, but it does not provide authentication or encryption itself.

func MarshalWireDocument

func MarshalWireDocument(document Document) ([]byte, error)

MarshalWireDocument encodes a document as typed wire JSON.

func MarshalWireValue

func MarshalWireValue(value Value) ([]byte, error)

MarshalWireValue encodes a typed value as wire JSON.

func ValidateStrictJSON

func ValidateStrictJSON(data []byte, maxBytes int) error

ValidateStrictJSON rejects oversized, trailing, deeply nested, and duplicate-key JSON before a transport decodes it into structs or maps.

Types

type ArchiveBootstrap

type ArchiveBootstrap = database.ArchiveBootstrap

ArchiveBootstrap binds an exact verified physical snapshot to the durable database change feed that was pinned before that snapshot began.

A receiver must persist and verify Backup, then drain and Ack every batch up through SnapshotToken without applying it (the snapshot already contains those effects). It can then apply and Ack later batches in order. This avoids the bootstrap/tail gap without inventing a second, weaker history contract.

type BackupResult

type BackupResult = database.BackupResult

BackupResult records the identity, size, and checksum of a physical backup.

func ImportPhysicalBackup

func ImportPhysicalBackup(ctx context.Context, source io.Reader, destination string, expected BackupResult, options PhysicalBackupImportOptions) (BackupResult, error)

ImportPhysicalBackup verifies a physical backup stream and publishes it at a new path.

It writes a private temporary file, checks the claimed byte count and SHA-256 while streaming, verifies the stored page structure and index contents, then publishes without overwriting an existing file and syncs the directory.

source is intentionally transport-neutral. A WebSocket, HTTP response, QUIC stream, or removable-media reader may supply it, but transport cancellation must close or honor ctx itself: a generic io.Reader cannot be interrupted while blocked in Read. The destination is never opened as a writable DB by this function; callers normally open the successfully imported file through OpenFollower before applying a replication tail.

type BackupStats

type BackupStats = database.BackupStats

BackupStats reports backup activity, sizes, and outcomes.

type Change

type Change = database.Change

Change records a document or catalog edit at a commit.

type ChangeBatch

type ChangeBatch = database.ChangeBatch

ChangeBatch groups changes under one ordered commit token.

type Collection

type Collection = database.Collection

Collection provides document operations for one named collection.

type CommitCoordinatorOptions

type CommitCoordinatorOptions = database.CommitCoordinatorOptions

CommitCoordinatorOptions sets the queue and batch limits for optional grouped writes.

Grouping is disabled by default.

A coordinator group publishes one stored database version but retains one logical commit token for every admitted write request, including prepared public write transactions. Index builds and other maintenance operations remain exclusive commits. When rollback protection is configured, the coordinator advances the external anchor after the group's stored version is durable and before acknowledging any member.

type CommitCoordinatorStats

type CommitCoordinatorStats = database.CommitCoordinatorStats

CommitCoordinatorStats reports queued writes, admission decisions, and commit groups.

DBStats and the versioned admin schema expose these bounded counters so applications can alert on queue pressure without inspecting the queue.

type CommitRetentionPolicy

type CommitRetentionPolicy = database.CommitRetentionPolicy

CommitRetentionPolicy limits retained history by commit count and encoded byte size.

Zero fields select production defaults. Active replay leases may temporarily exceed either budget rather than losing history under a reader.

type CommitStats

type CommitStats = database.CommitStats

CommitStats counts committed batches and their changes.

type CompactionOptions

type CompactionOptions = database.CompactionOptions

CompactionOptions sets storage and resource limits for a rewritten database.

ResourceLimits govern transient index construction as well as the reopened destination handle; zero fields select production defaults.

type CompactionStats

type CompactionStats = database.CompactionStats

CompactionStats reports compaction activity, byte counts, and outcomes.

type Cursor

type Cursor = database.Cursor

Cursor reads query results and releases their resources when closed.

type DB

type DB = database.DB

DB owns an in-memory or durable document database.

func New

func New() *DB

New creates an in-memory database with default limits.

func NewWithOptions

func NewWithOptions(options DatabaseOptions) (*DB, error)

NewWithOptions creates an in-memory database with explicit resource limits.

func Open

func Open(path string) (*DB, error)

Open creates or opens a Meldbase durable database in the current format.

func OpenWithOptions

func OpenWithOptions(path string, options OpenOptions) (*DB, error)

OpenWithOptions creates or opens a durable database with explicit storage and resource options.

type DBStats

type DBStats = database.DBStats

DBStats is a point-in-time, allocation-bounded view of database health.

Counters are process-lifetime values and reset when the database is reopened. Persistent state such as CommitSequence is read from the database itself.

Stats deliberately exposes no user values, document IDs, query parameters, or callbacks. It is safe for an admin sampler to call periodically, but it is not intended to be called on every database operation.

type DatabaseOptions

type DatabaseOptions = database.DatabaseOptions

DatabaseOptions configures an in-memory database.

type DeleteResult

type DeleteResult = database.DeleteResult

DeleteResult reports how many documents were deleted.

type DiagnosticEvent

type DiagnosticEvent = database.DiagnosticEvent

DiagnosticEvent records one operation's timing, outcome, and work counters.

type DiagnosticKind

type DiagnosticKind = database.DiagnosticKind

DiagnosticKind identifies the operation recorded by a diagnostic event.

type DiagnosticOutcome

type DiagnosticOutcome = database.DiagnosticOutcome

DiagnosticOutcome identifies how a recorded operation ended.

type DiagnosticSnapshot

type DiagnosticSnapshot = database.DiagnosticSnapshot

DiagnosticSnapshot captures a diagnostics session's counters and retained events.

type DiagnosticStats

type DiagnosticStats = database.DiagnosticStats

DiagnosticStats reports diagnostics activity and retained event counts.

type Diagnostics

type Diagnostics = database.Diagnostics

Diagnostics owns a bounded ring of recorded operation events.

Close disables timing and recording but keeps retained events readable.

type DiagnosticsOptions

type DiagnosticsOptions = database.DiagnosticsOptions

DiagnosticsOptions configures bounded diagnostic recording and event selection.

Defaults retain 256 events and record failures, queries taking at least 50ms, and commits taking at least 100ms. RecordAll is intended only for short development sessions. SampleEvery adds a deterministic one-in-N sample of otherwise fast successful operations.

type Document

type Document = database.Document

Document maps field names to typed database values.

func NewDocument

func NewDocument(fields map[string]any) (Document, error)

NewDocument converts Go fields into a document and rejects invalid names or values.

func UnmarshalWireDocument

func UnmarshalWireDocument(data []byte, limits QueryLimits) (Document, error)

UnmarshalWireDocument decodes a typed wire document with a required document ID.

func UnmarshalWireInputDocument

func UnmarshalWireInputDocument(data []byte, limits QueryLimits) (Document, error)

UnmarshalWireInputDocument decodes a typed wire document whose ID may be omitted.

type DocumentCacheStats

type DocumentCacheStats = database.DocumentCacheStats

DocumentCacheStats reports document-cache occupancy, hits, misses, and evictions.

type DocumentID

type DocumentID = database.DocumentID

DocumentID is a 16-byte document identifier.

func NewDocumentID

func NewDocumentID() (DocumentID, error)

NewDocumentID creates an identifier from cryptographically random bytes.

func ParseDocumentID

func ParseDocumentID(s string) (DocumentID, error)

ParseDocumentID reads a 16-byte identifier from a hexadecimal string.

type DurabilityStats

type DurabilityStats = database.DurabilityStats

DurabilityStats preserves legacy durability counters in the admin response format.

Current-format databases do not use a WAL or checkpoints, so every field is zero.

type DurableChangeBatch

type DurableChangeBatch = database.DurableChangeBatch

DurableChangeBatch contains one collection's document changes at a commit token.

Changes is empty when another collection or private catalog change advanced the durable position; callers must still Ack that Token after processing it so the checkpoint can advance without pinning history forever.

This is deliberately a document-change feed, not a full replication protocol: it does not expose private System records, index definitions, collection lifecycle or raw storage bytes.

type DurableChangeSubscription

type DurableChangeSubscription = database.DurableChangeSubscription

DurableChangeSubscription delivers ordered collection changes with a saved acknowledgement.

Ack must be called only after the consumer's external side effect for that token is durable.

type DurableDatabaseChangeBatch

type DurableDatabaseChangeBatch = database.DurableDatabaseChangeBatch

DurableDatabaseChangeBatch contains public document and catalog changes from one commit.

Archives and single-writer followers must acknowledge Token only after the externally applied effect is durable.

Private System records, raw pages, index-build progress and retention control records are deliberately excluded. A batch can therefore be empty when a private record advanced a retained position; it must still be Acked.

type DurableDatabaseChangeSubscription

type DurableDatabaseChangeSubscription = database.DurableDatabaseChangeSubscription

DurableDatabaseChangeSubscription delivers public database changes with a saved acknowledgement.

It exposes collection creation, index publication and document changes in exact Commit Log order. It does not itself copy a bootstrap snapshot or apply changes to a follower; those transport and ownership contracts are intentionally separate.

type ExplainAccessSource

type ExplainAccessSource = database.ExplainAccessSource

ExplainAccessSource records the query work performed through one index or primary key path.

CandidateIDs counts document IDs processed by the deduplicator. Read-ahead needed for an ordered union remains visible in KeysExamined even when execution stops before those IDs are consumed.

type ExplainAdvice

type ExplainAdvice = database.ExplainAdvice

ExplainAdvice records a possible query improvement to check against the workload.

It is not an instruction to create an index. Paths and Sort contain schema facts but never query values. Callers should validate selectivity against workload measurements.

type ExplainBound

type ExplainBound = database.ExplainBound

ExplainBound describes the values that restrict one indexed field.

Values is used for equality and membership unions; range bounds use Lower and Upper. A nil range endpoint is unbounded.

type ExplainBudget

type ExplainBudget = database.ExplainBudget

ExplainBudget is the final resource-budget snapshot for one execution.

Pressure and Exceeded are fixed reason codes naming one of "documents", "keys", "candidates", "sort_bytes", "skip", or "predicate_steps".

type ExplainResult

type ExplainResult = database.ExplainResult

ExplainResult describes the query plan and the work measured during execution.

Estimated fields are conservative candidate estimates when the selected backend can provide them; DocumentsExamined and KeysExamined are the actual completed scan counts. ResidualPredicate means the complete compiled predicate is rechecked after index admission, including when the index appears to cover every condition.

type Filter

type Filter = database.Filter

Filter maps document fields and query operators to their conditions.

type Follower

type Follower = database.Follower

Follower owns a read-only local database advanced by validated source change batches.

Transport authentication and snapshot transfer are managed outside this type; promotion requires the external authority and write guard described below.

func OpenFollower

func OpenFollower(path string, options OpenOptions) (*Follower, error)

OpenFollower opens a database copy as a read-only replica.

Normal public mutations on DB return ErrReplicaReadOnly; use Apply to advance the next source token. The returned DB remains fully queryable and reactive.

type FollowerPromotionAuthority

type FollowerPromotionAuthority = database.FollowerPromotionAuthority

FollowerPromotionAuthority grants promotion after durably revoking the former primary's write authority.

Implementations normally revoke a primary lease through a quorum controller or external consensus store.

type FollowerPromotionFence

type FollowerPromotionFence = database.FollowerPromotionFence

FollowerPromotionFence proves that the former primary lost write authority for this database version.

Epoch is non-empty and deliberately opaque to Meldbase: a controller may use it as an epoch ID or a compact signed lease certificate (as integrations/primarylease does). Meldbase does not invent a local substitute for that distributed safety decision.

type FollowerPromotionFenceBinder

type FollowerPromotionFenceBinder = database.FollowerPromotionFenceBinder

FollowerPromotionFenceBinder connects a promotion certificate to the local write protection guard.

The binder may update caller-owned local lease/epoch state, but must not enable writes until it has accepted the exact fence. It runs on the promotion control path, outside the DB writer lock; unlike ValidatePrimaryWrite it may coordinate with the controller if the implementation needs to.

A promoted follower requires this interface in addition to PrimaryWriteFence. Otherwise an unrelated always-allow guard could make a one-time promotion certificate appear to grant permanent write authority.

type FollowerPromotionRequest

type FollowerPromotionRequest = database.FollowerPromotionRequest

FollowerPromotionRequest identifies the database version requesting permission to become writable.

type IndexBuildFailure

type IndexBuildFailure = database.IndexBuildFailure

IndexBuildFailure identifies why an index build stopped permanently.

type IndexBuildID

type IndexBuildID = database.IndexBuildID

IndexBuildID identifies one durable, resumable Storage index build.

func ParseIndexBuildID

func ParseIndexBuildID(value string) (IndexBuildID, error)

ParseIndexBuildID parses a hexadecimal index-build identifier.

type IndexBuildPhase

type IndexBuildPhase = database.IndexBuildPhase

IndexBuildPhase identifies the current stage of a resumable index build.

type IndexBuildScheduler

type IndexBuildScheduler = database.IndexBuildScheduler

IndexBuildScheduler runs resumable index builds in bounded background tasks.

type IndexBuildSchedulerOptions

type IndexBuildSchedulerOptions = database.IndexBuildSchedulerOptions

IndexBuildSchedulerOptions configures polling, time slices, and build concurrency.

The scheduler must be started explicitly; each task yields durable progress between bounded time slices so document writes and other builds can proceed.

type IndexBuildSchedulerStats

type IndexBuildSchedulerStats = database.IndexBuildSchedulerStats

IndexBuildSchedulerStats reports background index-build activity and outcomes.

type IndexBuildStats

type IndexBuildStats = database.IndexBuildStats

IndexBuildStats reports index-build progress, resource use, and outcomes.

type IndexBuildStatus

type IndexBuildStatus = database.IndexBuildStatus

IndexBuildStatus reports the stored progress and outcome of a resumable index build.

EntryCount and CanonicalBytes describe the pending index tree, not transient Go heap usage.

type IndexCatalogEntry

type IndexCatalogEntry = database.IndexCatalogEntry

IndexCatalogEntry describes a published index without exposing document data.

Index management remains a deployment concern; this catalog supports CLIs and protected operator views.

type IndexDefinition

type IndexDefinition = database.IndexDefinition

IndexDefinition describes the ordered fields and uniqueness of an index.

type IndexField

type IndexField = database.IndexField

IndexField selects a field and its sort direction within an index.

Order must be 1 (ascending) or -1 (descending); fields are evaluated left to right.

type IndexOptions

type IndexOptions = database.IndexOptions

IndexOptions controls complete-tuple uniqueness.

type Kind

type Kind = database.Kind

Kind identifies the type stored in a Value.

type LogicalArchiveImportOptions

type LogicalArchiveImportOptions = database.LogicalArchiveImportOptions

LogicalArchiveImportOptions limits the size of an archive accepted for import.

Zero MaxBytes selects the normal storage-file limit; the receiver owns this cap.

type LogicalArchiveResult

type LogicalArchiveResult = database.LogicalArchiveResult

LogicalArchiveResult records archive counts, byte size, and checksum.

SHA256 covers every JSONL record before the final end record; the end record stores the same digest so an importer can reject truncation or alteration.

func ImportLogicalArchive

func ImportLogicalArchive(ctx context.Context, source io.Reader, destination string, options LogicalArchiveImportOptions) (result LogicalArchiveResult, resultErr error)

ImportLogicalArchive creates a new database from a validated logical archive.

Import and offline verification run in a private temporary database before atomic publication, so a malformed archive leaves no destination database.

type Maintenance

type Maintenance = database.Maintenance

Maintenance runs background tasks that make unused database pages reusable.

Stop waits for an active scan to observe cancellation; closing the database also cancels the loop.

type MaintenanceOptions

type MaintenanceOptions = database.MaintenanceOptions

MaintenanceOptions sets the schedule and limits for background page reclamation.

Each loop uses online optimistic reclamation and never overlaps its own runs.

type MaintenanceStats

type MaintenanceStats = database.MaintenanceStats

MaintenanceStats counts background page reclamation runs and records their outcomes.

type MutationSpec

type MutationSpec = database.MutationSpec

MutationSpec holds a compiled document update.

func CompileUpdate

func CompileUpdate(update Update) (MutationSpec, error)

CompileUpdate validates update operators and produces a reusable mutation.

func DecodeMutationSpecJSON

func DecodeMutationSpecJSON(data []byte, limits QueryLimits) (MutationSpec, error)

DecodeMutationSpecJSON validates and decodes a data-only mutation within the supplied limits.

type OpenOptions

type OpenOptions = database.OpenOptions

OpenOptions configures the current durable storage format.

type Operation

type Operation = database.Operation

Operation identifies a document or catalog change.

type OperationalState

type OperationalState = database.OperationalState

OperationalState is a minimal, allocation-free serving-state snapshot.

A fail-stop durability error preserves reads from the last committed state but disables writes; a closed database is neither readable nor writable.

type PageCacheStats

type PageCacheStats = database.PageCacheStats

PageCacheStats reports page-cache occupancy, hits, misses, and evictions.

type PhysicalBackupImportOptions

type PhysicalBackupImportOptions = database.PhysicalBackupImportOptions

PhysicalBackupImportOptions limits the bytes accepted from a physical backup stream.

Zero selects the normal file limit. Deployments with a deliberately larger database must set MaxBytes explicitly on the receiving side; a sender never chooses that authority.

type PrimaryWriteFence

type PrimaryWriteFence = database.PrimaryWriteFence

PrimaryWriteFence checks whether an external authority still permits a local write.

Its implementation normally checks an atomically refreshed lease epoch and expiry, not the network. Returning an error rejects the whole logical commit before storage mutation; it never poisons the database or advances a token.

Implementations must not call back into DB and must return promptly: the check runs while the writer has admitted a commit. Election, renewal, certificate rotation and old-primary revocation remain external concerns.

type PrimaryWriteFenceRequest

type PrimaryWriteFenceRequest = database.PrimaryWriteFenceRequest

PrimaryWriteFenceRequest identifies the database and next commit requiring write authority.

A lease implementation must reject when its external authority/epoch/expiry no longer permits that write.

type PrimaryWriteFenceStats

type PrimaryWriteFenceStats = database.PrimaryWriteFenceStats

PrimaryWriteFenceStats reports whether write protection is active and counts its checks and rejections.

Configured means a guard was supplied at open; Enforced is false while a read-only follower applies validated source history. Checks and Rejected count only actual primary write admissions. No lease, epoch, endpoint, database ID, or controller detail is exposed.

type QueryDelta

type QueryDelta = database.QueryDelta

QueryDelta transforms exactly FromToken into Token.

Operations are ordered: removals first, followed by reverse-order add/move anchors and document changes. Applying them in slice order is deterministic.

type QueryDeltaOperation

type QueryDeltaOperation = database.QueryDeltaOperation

QueryDeltaOperation mutates an ordered query result.

A zero BeforeID means the end of the result; database document IDs are never zero.

type QueryDeltaOperationKind

type QueryDeltaOperationKind = database.QueryDeltaOperationKind

QueryDeltaOperationKind identifies a change to an ordered query result.

type QueryDeltaSubscription

type QueryDeltaSubscription = database.QueryDeltaSubscription

QueryDeltaSubscription returns one safe initial snapshot and then ordered deltas.

It is the preferred core stream for transports and reactive clients; QuerySubscription remains the full-snapshot compatibility adapter.

type QueryLimits

type QueryLimits = database.QueryLimits

QueryLimits bounds the size and complexity of accepted queries.

type QueryOptions

type QueryOptions = database.QueryOptions

QueryOptions configures query sorting and pagination.

type QueryReplaySource

type QueryReplaySource = database.QueryReplaySource

QueryReplaySource atomically reconstructs a query at afterToken and tails later ordered revisions.

Initial.Token must equal afterToken. Implementations return ErrHistoryLost when retention can no longer satisfy that contract.

type QueryReplaySubscription

type QueryReplaySubscription = database.QueryReplaySubscription

QueryReplaySubscription provides a historical query snapshot and its later changes.

type QuerySnapshot

type QuerySnapshot = database.QuerySnapshot

QuerySnapshot pairs an ordered query result with its commit token.

func ApplyQueryDelta

func ApplyQueryDelta(snapshot QuerySnapshot, delta QueryDelta) (QuerySnapshot, error)

ApplyQueryDelta strictly validates and applies an ordered delta without mutating the input snapshot.

type QuerySpec

type QuerySpec = database.QuerySpec

QuerySpec holds a compiled filter with sorting and pagination.

func CompileQuery

func CompileQuery(filter Filter, options QueryOptions) (QuerySpec, error)

CompileQuery validates a filter and options to produce a reusable query.

func DecodeQuerySpecJSON

func DecodeQuerySpecJSON(data []byte, limits QueryLimits) (QuerySpec, error)

DecodeQuerySpecJSON validates and decodes a data-only query within the supplied limits.

type QueryStats

type QueryStats = database.QueryStats

QueryStats counts query activity and execution work during the current process session.

Physical key and candidate counters include work completed before a failed query; the older document/return counters retain their successful-query contract.

type QuerySubscription

type QuerySubscription = database.QuerySubscription

QuerySubscription provides full query snapshots as the result changes.

type RealtimeStats

type RealtimeStats = database.RealtimeStats

RealtimeStats reports live query activity, queued work, and overloads.

type ReclaimOptions

type ReclaimOptions = database.ReclaimOptions

ReclaimOptions configures page-reclamation mode, retries, and persistence.

Online scans a duplicate read handle without the storage writer lock and installs its result only if the Meta generation is unchanged. MaxAttempts bounds complete graph rescans after concurrent commits; zero selects three attempts.

type ReclaimResult

type ReclaimResult = database.ReclaimResult

ReclaimResult reports reachable and reusable pages after reclamation.

type ReclamationStats

type ReclamationStats = database.ReclamationStats

ReclamationStats reports page-reclamation activity and outcomes.

type RecoveryMode

type RecoveryMode = database.RecoveryMode

RecoveryMode selects whether startup may perform bounded recovery actions.

Zero selects automatic recovery; RecoveryReport describes completed actions.

type RecoveryReport

type RecoveryReport = database.RecoveryReport

RecoveryReport records completed startup recovery actions without exposing sensitive data.

It reports only actions that were completed before Open returned successfully; corruption and unsupported formats still fail Open instead of being described as recovered.

type ReplicationFrame

type ReplicationFrame = database.ReplicationFrame

ReplicationFrame carries a handshake, change batch, acknowledgement, or resync request.

A transport must authenticate both peers (for example with mTLS) before it accepts frames; DatabaseID binds every frame to one durable source identity.

func UnmarshalReplicationFrame

func UnmarshalReplicationFrame(data []byte, limits ReplicationFrameLimits) (ReplicationFrame, error)

UnmarshalReplicationFrame validates and decodes a bounded JSON replication message.

It rejects unknown fields, duplicate keys, malformed base64, invalid typed documents, and non-canonical identities before the follower receives a batch.

type ReplicationFrameLimits

type ReplicationFrameLimits = database.ReplicationFrameLimits

ReplicationFrameLimits caps the size of a decompressed replication message.

The default accommodates the configured 64 MiB canonical transaction limit plus JSON/base64 overhead, while still rejecting unbounded peer allocation.

type ReplicationSourceLease

type ReplicationSourceLease = database.ReplicationSourceLease

ReplicationSourceLease reserves a replica consumer for one session in this process.

It prevents sessions from racing the same checkpoint and does not replace external primary election or follower-promotion fencing.

type ReplicationSourceSession

type ReplicationSourceSession = database.ReplicationSourceSession

ReplicationSourceSession sends committed database changes to one authenticated receiver.

Only one batch may await acknowledgement at a time, limiting queued work and preventing acknowledgement of an unseen source token.

func NewReplicationSourceSession

func NewReplicationSourceSession(db *DB, subscription *DurableDatabaseChangeSubscription, limits ReplicationFrameLimits) (*ReplicationSourceSession, error)

NewReplicationSourceSession creates a replication session from a named database change feed.

The caller authenticates the receiver and must close the session when that authenticated connection ends.

type ResourceLimits

type ResourceLimits = database.ResourceLimits

ResourceLimits bounds work admitted by writes, index maintenance, and query execution.

Zero values select production defaults; limits cannot be disabled accidentally. Byte limits use the canonical typed binary representation, independent of Go heap layout, JSON spelling, storage generation, or transport compression.

type ResourceStats

type ResourceStats = database.ResourceStats

ResourceStats reports configured resource limits and rejection counts.

type RollbackAnchor

type RollbackAnchor = database.RollbackAnchor

RollbackAnchor records trusted minimum commit and generation values outside the database.

A server must never accept the same identity below either an acknowledged logical commit sequence or physical maintenance generation after restart. The coordinates are independently monotonic: one group may advance several logical sequences while publishing a single physical generation.

type RollbackAnchorStatusProvider

type RollbackAnchorStatusProvider = database.RollbackAnchorStatusProvider

RollbackAnchorStatusProvider exposes anchor store counters without acquiring locks.

type RollbackAnchorStore

type RollbackAnchorStore = database.RollbackAnchorStore

RollbackAnchorStore loads and durably advances a database's trusted rollback boundary.

Advance must not return until the anchor is persistent and must reject identity changes or regression of either monotonic coordinate. Implementations must be safe for concurrent callers and honor cancellation. An Advance error does not prove that state was unchanged: persistence may have completed before a response, deadline or cancellation was observed.

func NewFileRollbackAnchorStore

func NewFileRollbackAnchorStore(path string) (RollbackAnchorStore, error)

NewFileRollbackAnchorStore creates a file-backed store for trusted database version limits.

Updates replace the anchor atomically and reject invalid saved state. The parent directory must exist on storage trusted independently from the database.

type RollbackAnchorStoreStatus

type RollbackAnchorStoreStatus = database.RollbackAnchorStoreStatus

RollbackAnchorStoreStatus reports anchor backend counters without exposing database identities.

These diagnostic counters never participate in recovery.

type RollbackProtection

type RollbackProtection = database.RollbackProtection

RollbackProtection configures identity and progress checks that reject database rollback.

AnchorStore should live on an independently trusted device or remote quorum; placing it beside the database cannot detect whole-device rollback. InitializeAnchor explicitly trusts the database currently at Path when the store is empty and should only be used during provisioning or audited restore.

type SortField

type SortField = database.SortField

SortField specifies a document path and its ascending or descending sort direction.

type StorageFormat

type StorageFormat = database.StorageFormat

StorageFormat identifies the supported file format or an absent database.

Unknown denotes a missing or zero-length path, not an unrecognized non-empty file.

func DetectStorageFormat

func DetectStorageFormat(path string) (StorageFormat, error)

DetectStorageFormat distinguishes an absent database from a recognized database format.

Old database files deliberately fail closed: this build contains no legacy reader or automatic migration path.

type StorageFormatInfo

type StorageFormatInfo = database.StorageFormatInfo

StorageFormatInfo reports file format metadata and compatibility with this reader.

ReaderCompatible says this binary understands the reported revision and all required feature bits; callers must still Open the database before use.

func InspectStorageFormat

func InspectStorageFormat(path string) (StorageFormatInfo, error)

InspectStorageFormat validates current Meta checksums and reports its newest readable envelope without opening the database for mutation.

type StorageLimits

type StorageLimits = database.StorageLimits

StorageLimits caps the physical database file size.

Zero selects DefaultMaxFileBytes; the limit must be a multiple of the 16 KiB page size.

type StorageStats

type StorageStats = database.StorageStats

StorageStats describes the selected physical backend.

Session counters reset on reopen; physical state and cache counters come from the backend itself.

type Update

type Update = database.Update

Update maps update operators to their requested field changes.

type UpdateResult

type UpdateResult = database.UpdateResult

UpdateResult reports how many documents matched and changed.

type Value

type Value = database.Value

Value stores typed database data behind a private representation.

Private fields prevent callers from pairing a type with an incompatible payload.

func Array

func Array(v ...Value) Value

Array creates an array value from copies of its elements.

func Binary

func Binary(v []byte) Value

Binary creates a binary value from a copy of the bytes.

func Bool

func Bool(v bool) Value

Bool creates a boolean value.

func Float

func Float(v float64) Value

Float creates a 64-bit floating-point value.

func ID

func ID(v DocumentID) Value

ID creates a document identifier value.

func Int

func Int(v int64) Value

Int creates a signed 64-bit integer value.

func Null

func Null() Value

Null creates a null value.

func Object

func Object(v Document) Value

Object creates an object value from a copy of the document.

func String

func String(v string) Value

String creates a string value.

func Time

func Time(v time.Time) Value

Time stores millisecond precision, matching JavaScript Date and the wire contract.

Precision is normalized at construction rather than silently lost during transport.

func UnmarshalWireValue

func UnmarshalWireValue(data []byte, limits QueryLimits) (Value, error)

UnmarshalWireValue decodes a typed JSON value within the supplied query limits.

It applies the same nesting, item count, and size limits as query operands. Protocol arguments such as RPC inputs contain data only; decoding never runs code.

func ValueOf

func ValueOf(x any) (Value, error)

ValueOf converts a supported Go value into a database value with copied nested data.

type VerificationReport

type VerificationReport = database.VerificationReport

VerificationReport records the results of a read-only page and index audit.

ReclaimablePages is informational; verification never installs a free pool or publishes maintenance metadata.

func VerifyFile

func VerifyFile(ctx context.Context, path string) (VerificationReport, error)

VerifyFile checks an existing database's protected pages and index contents without changing it.

It takes a non-blocking shared advisory lock, so an active writer fails with ErrDatabaseLocked. It never creates, truncates, repairs, reclaims, or advances the database. Meta inspection alone is cheaper; this method walks every page protected by both valid Meta roots, recomputes published and provable shadow Secondary keys from canonical Primary documents in both directions, and hashes the file. Legacy caught-up builds lacking an applied CatalogRoot remain readable but report IndexBuildContentsVerified=false.

type WriteTransaction

type WriteTransaction = database.WriteTransaction

WriteTransaction stages reads and writes against a snapshot for an atomic commit.

Commit validation detects conflicting changes, and returned values are independent copies.

A transaction is active only during its handler callback. Handlers must not retain it or call normal DB/Collection methods from inside the callback.

type WriteTransactionStats

type WriteTransactionStats = database.WriteTransactionStats

WriteTransactionStats counts active transactions and their outcomes.

Every started callback reaches exactly one terminal counter. These aggregates do not contain collection, document, actor, or callback identifiers.

Directories

Path Synopsis
Package admin provides database monitoring and operator HTTP endpoints.
Package admin provides database monitoring and operator HTTP endpoints.
cmd
meld command
integrations
anchorhttp
Package anchorhttp reads and advances rollback anchors through authenticated HTTPS members.
Package anchorhttp reads and advances rollback anchors through authenticated HTTPS members.
authorityhttp
Package authorityhttp serves write lease grants and revocations over authenticated HTTPS.
Package authorityhttp serves write lease grants and revocations over authenticated HTTPS.
leasehttp
Package leasehttp provides authenticated HTTPS access to one controller member's lease records.
Package leasehttp provides authenticated HTTPS access to one controller member's lease records.
otel
Package meldotel exports sampled Meldbase statistics through OpenTelemetry metrics.
Package meldotel exports sampled Meldbase statistics through OpenTelemetry metrics.
primarylease
Package primarylease supplies a locally verifiable, short-lived primary write lease for Meldbase deployments.
Package primarylease supplies a locally verifiable, short-lived primary write lease for Meldbase deployments.
replicationauth
Package replicationauth verifies peer identities for server-to-server replication.
Package replicationauth verifies peer identities for server-to-server replication.
replicationhttp
Package replicationhttp transfers verified database snapshots over HTTPS.
Package replicationhttp transfers verified database snapshots over HTTPS.
replicationws
Package replicationws transfers database changes between trusted servers over WebSocket.
Package replicationws transfers database changes between trusted servers over WebSocket.
internal
database
Package database implements the Meldbase database API behind the module-root public package.
Package database implements the Meldbase database API behind the module-root public package.
policyrecord
Package policyrecord encodes the stored versions of server query policies.
Package policyrecord encodes the stored versions of server query policies.
qualification
Package qualification runs operational checks and records evidence for releases.
Package qualification runs operational checks and records evidence for releases.
storage
Package storage implements the current Meldbase copy-on-write page format.
Package storage implements the current Meldbase copy-on-write page format.
systemrecord
Package systemrecord lets built-in services read and change private database records.
Package systemrecord lets built-in services read and change private database records.
Package server gives applications authenticated HTTP, live-query, and RPC access to Meldbase.
Package server gives applications authenticated HTTP, live-query, and RPC access to Meldbase.

Jump to

Keyboard shortcuts

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