asobi_readiness (asobi v0.75.1)

View Source

Whether the node is ready to serve extension traffic.

There is a window in which an extension endpoint exists but its tables do not. The dispatch tree is compiled during Nova's boot, inside nova_sup:init/1; kura_migrator:migrate/1 runs later, from asobi_app:start/2. Anything listening in between would reach a handler whose tables have not been created.

So core signals readiness once, after migrations, and the seam below fails closed until then.

The seam

guard/0 is what the RPC dispatcher calls before dispatching:

case asobi_readiness:guard() of
    ok -> dispatch(Method, Params);
    {error, Object} -> {asobi_error, 503, Object}
end.

The dispatcher itself is Wave 2b and does not exist yet. guard/0 and the not_ready code do, and they are tested, so the dispatcher inherits a readiness contract rather than inventing one.

persistent_term rather than a process: the read is on the dispatch path, it happens once per call, and the value is written exactly once at boot.

The other reader

asobi_extension_sup reads ready/0 at init/1. Migrations run before asobi_sup:start_link/0, so the answer is already final by then, which is what lets an extension's own sup/0 children query at init/1 without a retry path: either the database is there, or no extension started at all.

Summary

Functions

ok when the node may serve extension traffic, otherwise the error object to return with HTTP 503.

Called once from asobi_app:start/2, after kura_migrator:migrate/1 returns {ok, _}. A failed migration deliberately leaves the node not ready.

Whether migrations have run to completion on this node.

Functions

guard()

-spec guard() -> ok | {error, asobi_error:object()}.

ok when the node may serve extension traffic, otherwise the error object to return with HTTP 503.

mark_ready()

-spec mark_ready() -> ok.

Called once from asobi_app:start/2, after kura_migrator:migrate/1 returns {ok, _}. A failed migration deliberately leaves the node not ready.

ready()

-spec ready() -> boolean().

Whether migrations have run to completion on this node.