server

package
v5.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package server executes off-thread database requests against a real SQLite database (plan item P3.5).

This is the half that links the engine. It imports db/sqlite, which imports ncruces/go-sqlite3, which embeds wazero — roughly a megabyte of wasm interpreter. Compiling this package into domain.wasm and NOT into app.wasm is the entire point of the split, and it is what criterion (b) checks.

A Server is single-threaded by construction, matching both the worker it runs in and the one-connection pool underneath it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalTransport

type LocalTransport struct {
	// contains filtered or unexported fields
}

LocalTransport runs a Server in-process, implementing offthread.Transport.

It exists so an app can develop and test against the off-thread API without a worker, and so criterion (c) — a mixed app using both models — has something to exercise. It is NOT the production path: running the server in-process puts the engine back on the calling thread, which is the thing being avoided.

func NewLocalTransport

func NewLocalTransport(parseServer *Server) *LocalTransport

NewLocalTransport wraps a server as an in-process transport.

func (*LocalTransport) Call

func (parseTransport *LocalTransport) Call(parseCtx context.Context, parseRequest offthread.Request) (offthread.Response, error)

Call executes a request in-process.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server answers offthread.Request against a SQLite database.

func New

func New(parseDB *sqlite.DB) (*Server, error)

New wraps an open database in a request server.

func (*Server) Handle

func (parseServer *Server) Handle(parseCtx context.Context, parseRequest offthread.Request) offthread.Response

Handle executes one request and returns its response.

It never returns a Go error: every failure travels in Response.Err, because the response is what crosses the thread boundary. A transport that also returned an error would give the client two channels for the same failure and invite it to check only one.

func (*Server) OpenTransactionCount

func (parseServer *Server) OpenTransactionCount() int

OpenTransactionCount reports how many transactions are open, for diagnostics and for tests asserting that failure paths do not leak them.

Jump to

Keyboard shortcuts

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