replhook

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package replhook gives the replicator (replica/internal/capture) what it needs of the driver and the driver does not offer its users. Package sqlite fills it in as it is initialized.

Index

Constants

View Source
const WALWait = 100 * time.Millisecond

WALWait is how long a checkpoint that starts the WAL over, once it is past the limit of a connection, waits for the readers: by the driver for a file that is not replicated, by the replicator for one that is.

Variables

View Source
var Attach func(path string, committed func(frames uint32, limit int64)) (detach func(), err error)

Attach makes every connection the driver opens to the database file path from then on ready for replication: no automatic checkpoints, and the PRAGMAs that would checkpoint refused (csqlite.Conn.SetGuard). The file must exist. It is found by what it is, so a connection that names it another way (case, a short windows name) is covered too. It fails when the driver has a connection to the file open, or the file is attached already. detach ends it: connections opened after it are as before.

committed, if not nil, is called each time a connection of the driver that held the file's write lock ends its transaction, before the lock goes to the next writer, with the frames in the WAL as it is then (csqlite.Conn.WALNow). A connection that never read the WAL does not call it: it wrote nothing there. It runs on the writer's goroutine and holds the lock meanwhile: the writers of the file wait for it, and it must not take the lock (Lock). limit is the length of the WAL in bytes past which that connection wants it started over, 0 for never (its _wal_limit): on an attached file the driver leaves that to committed.

View Source
var Lock func(ctx context.Context, path string) (unlock func(), err error)

Lock takes the driver's write lock of an attached file, as a writer does, waiting until ctx is done: until unlock, no connection of this process writes to the file.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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