wasm_storage_deadline (wasm_storage v0.1.0)

View Source

Deadlines as the database servers pass them around.

A request to a database carries one absolute deadline, a monotonic time in milliseconds or infinity, computed once in the caller. The server, a reader and the guest call all apply that same deadline, so a request that waits in a queue or for a reopen never gets more time than its caller gave it. The engines' API modules send requests with call/3; their servers use the rest.

Summary

Functions

Send {Req, Expiry} to a database server and wait for its reply. The server answers before the deadline; the extra second lets its answer arrive after a guest that ran out of time was stopped. A server that is gone answers {error, closed}; one that did not answer in time, {error, timeout}.

Whether the deadline has passed.

The deadline Timeout milliseconds from now.

Have Msg sent to the calling process when the deadline passes; nothing for infinity. A server uses it to answer the callers waiting in its queues.

The milliseconds left before the deadline, at least 1: a timeout for a call that must not start once the deadline has passed, which expired/1 checks first.

Types

expiry()

-type expiry() :: integer() | infinity.

Functions

call(Server, Req, Timeout)

-spec call(gen_server:server_ref(), term(), timeout()) -> term().

Send {Req, Expiry} to a database server and wait for its reply. The server answers before the deadline; the extra second lets its answer arrive after a guest that ran out of time was stopped. A server that is gone answers {error, closed}; one that did not answer in time, {error, timeout}.

expired/1

-spec expired(expiry()) -> boolean().

Whether the deadline has passed.

expiry/1

-spec expiry(timeout()) -> expiry().

The deadline Timeout milliseconds from now.

notify/2

-spec notify(expiry(), term()) -> ok.

Have Msg sent to the calling process when the deadline passes; nothing for infinity. A server uses it to answer the callers waiting in its queues.

remaining/1

-spec remaining(expiry()) -> timeout().

The milliseconds left before the deadline, at least 1: a timeout for a call that must not start once the deadline has passed, which expired/1 checks first.