Expand description
The client engine (packages/zero-client/src/client): the connection,
the replica and its pending mutations, and the query and mutation
bookkeeping, on memory storage.
Everything runs synchronously on one thread, driven by a Scheduler
and the socket events of a SocketFactory; see event_loop.
Structs§
- Analyze
Query Options - What
Inspector::analyze_queryasks the server for besides the basics (AnalyzeQueryOptions). Options leftNoneare not sent. - Analyze
Query Result - The server’s analysis of a query (
AnalyzeQueryResultinpackages/zero-protocol/src/analyze-query-result.ts). - Application
Error - An error a mutator raised for the app to handle, or that the API server
reported for a mutation (
ApplicationErrorinpackages/zero-protocol/src/application-error.ts). Return it from a mutator to give the caller a message and details. - Client
Group Record - A client group: the clients that share a replica because they register
the same mutators (
ClientGroup). - Client
IdPair - A deleted client the server may not know about yet.
- Client
Record - A client that used the database (
ClientV6). - Connection
- The connection to zero-cache (
Connectioninpackages/zero-client/src/client/connection.ts). - Deferred
- A value that arrives later, like a JS promise: the first
resolveorrejectwins.resultreads it without waiting; aDeferredis also a future that waits for it. - Dropped
Databases - What
Zero::deleteanddrop_all_databasesdeleted. - Inspector
- The inspector of a client (
Inspectorininspector/inspector.ts), fromZero::inspector. - Inspector
Client - A client in the local store (
Clientininspector/client.ts). - Inspector
Client Group - A client group in the local store (
ClientGroupininspector/client-group.ts). - Inspector
Query - A query as the server and the client know it (
Queryininspector/query.ts): one row of the server’squeriesanswer, with the client’s metrics merged in. - Materialized
View - A view of a query that stays current as data changes (
TypedView). - Metrics
- The client’s and the server’s query metrics (
Metricsinlazy-inspector.ts), each a digest of times in ms. - Mutate
Request - A mutator applied to its arguments, ready for
Zero::mutate_request(MutateRequestin JS and Swift). Adefine_mutatordefinition makes one withwith. - Mutator
- A mutator the client can run and replay by name (
defineMutatorinpackages/zql/src/mutate/mutator.ts). The name must match the TS registry entry the API server runs. - Mutator
Result - What
mutatereturns: the outcome of the optimistic run on the client, and the server’s. - Plan
Debug Event - One of the planner’s debug events (
PlanDebugEventJSONinpackages/zero-protocol/src/analyze-query-result.ts), as JSON: itstypesays which. - Preload
- What
preloadreturns. - Query
Error - A query the server could not run.
- Stderr
LogSink - The default sink: standard error.
- Storage
Failure - A failure of the local storage, rather than of its data
(
StorageFailureError): the client keeps running on memory. - Stored
Clients - What a database holds besides the groups’ data, read when it opens.
- Stored
Group - What a client group keeps: the last server snapshot and the mutations not yet in it.
- Stored
Mutation - A mutation that ran on a client and the server has not confirmed.
- Table
Mutator - The CRUD operations on one table (
TableCRUDinpackages/zql/src/mutate/crud.ts). Values are keyed by client column name. - Transaction
- The transaction a mutator runs in.
- Update
Needed Reason - Why the client must be updated (
UpdateNeededReason). - Zero
- A Zero client: syncs the rows of named queries from zero-cache into a local replica, keeps materialized views of them current, and runs mutators optimistically before the server confirms them.
- Zero
Options - The options of a Zero client (
ZeroOptionsinpackages/zero-client/src/client/options.ts).
Enums§
- Client
Error Kind - The kinds of error the client raises itself
(
packages/zero-client/src/client/client-error-kind-enum.ts). - Connection
Error - Why a connection ended or could not be made: an error the client raised
(
ClientError) or one the server sent (ProtocolError), togetherZeroErrorinpackages/zero-client/src/client/error.ts. - Connection
State - The connection state an app sees (
ConnectionStateinpackages/zero-client/src/client/connection.ts). - Connection
Status - The status names (
packages/zero-client/src/client/connection-status-enum.ts). - Error
- An error of the client’s API.
- Load
Error - Why a database couldn’t be read.
- LogLevel
- How much the client logs (
LogLevel). A level includes the levels after it:Warnlogs warnings and errors. - Mutation
Outcome - How a mutation ended, on the client or on the server
(
MutatorResultDetailsinpackages/zero-client/src/client/custom.ts). - Needs
Auth Reason - Why the client needs new credentials.
- Reason
- Why a mutator runs.
- RunType
- Which rows
Zero::runreturns. - Socket
Message - A frame from the server.
- Storage
Failure Kind - What part of the store failed.
- Storage
Op - A change to the database, applied in order.
- Zero
Storage - Where a client keeps its replica (
ZeroStoragein zero-swift,kvStorein JS).
Traits§
- LogSink
- Where the client’s log messages go (
LogSink). - Scheduler
- The clock and timers the engine runs on:
Date.now(),performance.now()andsetTimeoutin JS. Tests useManualSchedulerso a scenario runs the same way every time; an app’s transport provides one that runs on its event loop. - Socket
Connection - An open or opening WebSocket.
- Socket
Events - Receives the events of one socket.
- Socket
Factory - Opens the sync socket. Every call is on the engine’s thread.
- Storage
Backend - A place that keeps a client’s databases, such as a directory of SQLite files. Every call is on the client’s thread.
- Stored
Database - An open database of a
StorageBackend. - Timer
- A timer from
Scheduler::schedule.
Functions§
- drop_
all_ databases - Deletes every Zero database in
storage, of every user (dropAllDatabases). Clients still open on one keep running on what they have in memory, and their later writes are dropped. - timer_
delay - The delay
setTimeoutandsetIntervalwait forms: none for NaN, a negative delay, or one past 2^31 - 1 ms, which browsers and Node fire at once.
Type Aliases§
- Aggregate
Writes - The synced aggregate rows (
a/keys) a mutation’s last run wrote, with their values after it (Nonefor deleted). - Batch
View Updates ZeroOptions::batch_view_updates: called with the function that updates the views.- RowCounts
BySource - Row counts by source, then by query.
- Rows
ByQuery - Rows by query (or table).
- Rows
BySource - Rows by source, then by query.
- Storage
Failure Handler - Called when the local store fails (
onStorageFailure). - Update
Needed Handler - Called when the server needs a newer client (
onUpdateNeeded). - View
Listener - Called with a view’s data, result type, and error.