gizdb/local
the GizDB engine in this process, the one owner of that path. It serves a folder (serve), and gives typed records (gizmodel/data) their engine as a Data.Engine. gizmodel/data, gizmodel/store and the record layer import no engine module, so an app on SQLite or PostgreSQL links none. Only .giz programs reach it.
import * as Local from "gizdb/local";Types
Endpoint
type Endpoint = { endpoint: Access.Endpoint; identity: string; secret: bytes; }Where typed connections reach an engine this process serves, from any thread.
endpoint:M101.Endpointidentity:stringsecret:bytes
Served
type Served = { engine: Data.Engine; endpoint: Endpoint; stop: () => void; }A GizDB folder this process serves (serve): its engine for typed records (Data.open with engine, Data.connect), where it is, and STOP,
which stops its server after a checkpoint. A connection to it is Store.open of its folder, as from any other process.
engine:M127.Engineendpoint:M106.Endpointstop:() => void
Options
type Options = { sync: bool; }How a served folder keeps a commit. With sync (the default) a commit answers after the disk holds it: it survives a
power loss. Without it a commit answers when the operating system has it: it survives the end of the process, and a
power loss may lose the last commits (never a part of one).
sync:bool
Functions
memory
function memory(): Served throws SqlErrorServes a new, empty GizDB in memory until Served.stop, which ends it: nothing of it stays. Its files are in the
host's memory file system where there is one, else in the temporary folder, and no commit waits for a disk. A
database to keep, in memory or not, is serve of a folder you name, with { sync: false } to not wait for the disk.
Effects: fail, read, write, console, io, alloc.
serve
function serve(location: string, how: Options = { sync: true }): Served throws SqlErrorServes the GizDB folder location in this process until Served.stop: its engine for typed records (Data.open with engine), and the
PostgreSQL server at its unix socket, which every connection reaches with Store.open, this process's too. Its first
start moves in the SQLite file location.db when there is one (Store.movedIn). A folder that a process serves already
is an error: serving has one owner.
Effects: fail, read, write, console, io, alloc.
engineOf
function engineOf(endpoint: Endpoint): Data.EngineThe engine at ENDPOINT as typed records take it (Data.Engine).
Effects: fail, alloc.
connectTo
function connectTo(endpoint: Endpoint): Access.Connection throws DbErrorA connection of its own to ENDPOINT.
Effects: fail, io, alloc.
db
function db(connection: Access.Connection, name: string): Data.DbThe database NAME of CONNECTION, on the GizDB engine: every call goes to its data actor. Data.open reads on its thread.
Effects: fail, alloc.
engineDb
function engineDb(connection: Access.Connection, name: string, lane: Option<Access.Lane>): Data.DbThe database NAME of CONNECTION, whose reads run on LANE when it has one (Data.open makes its own lane).
Effects: fail, alloc.
Methods
Endpoint.connect
function Endpoint.connect(self: Endpoint, name: string): Data.Db throws DbErrorNAME on a connection of its own whose calls all go to the data actor (a factory that may make no state of its thread, App.Serving.uploads).
Effects: fail, io, alloc.
Endpoint.of
function Endpoint.of(self: Endpoint, name: string): Data.Db throws DbErrorNAME on a connection of its own whose reads run on the thread of SYS (Access.Lane).
Effects: fail, read, write, io, alloc.