Module proto
Expand description
The server-mode wire protocol, carried in fusee_core::frame frames.
A worker (an application process running workflow code) leases the server’s shards and drives each shard’s runtime against the server’s storage. Every request carries the lease epoch; the server refuses stale epochs, so a worker that lost its lease can never append again.
Modules§
Structs§
- Head
- Header of every request after the kind byte:
id, shard, epoch.
Constants§
- DURABLE_
PINS - A
DURABLEflag: one more checkpoint of the shard lets the log retire its oldest segment. - EXCLUSIVE_
LOG - The worker’s engine is the only writer of the shard’s segment files, so its recovery may delete trailing segments without a valid record and reuse their numbers. Not granted over replicated storage, where the replica’s applier writes segments too. No parameters.
- FIRST_
SEGMENT_ LIMIT - IDLE_
BUSY - Bit 0 of an
IDLEentry’s flags: the shard still had work. - IDLE_
EXPIRED - Bit 1 of an
IDLEentry’s flags: the invocation’s budget ended. - INVOKED
- An invoked worker (
crate::invoke):HELLOcarries, after the most shards to hold, the invocation’s IDu64. The server grants that invocation’s free shards at once, never more and never later (no standby), or refuses the connection. The lease parameter isremaining_ms u32, the invocation’s budget left. Granted withSHARD_LEASESonly. The worker drains (DRAIN) and reports (IDLE) before it leaves. - LEASE_
LIVENESS - The worker sends
PINGat least every interval while it holds the lease; the server revokes the lease after the timeout without traffic. The lease parameters areping_interval_ms u32, timeout_ms u32. Granted only to a worker that offered it. - MESSAGE_
RELAY - Messages between workflows on shards held by different workers go
through the server (
RELAY,RELAY_ACKS,MESSAGES,MESSAGE_ACKS). Granted withSHARD_LEASES. No parameters. - PAGED_
RECOVERY - RECOVERY_
PAGE - SHARD_
LEASES - Shards are leased one at a time, each with its own epoch.
HELLOcarries, after the offer, the most shards the worker takes at once (0: all). The lease parameter is the shards granted now:count u32, then shard u32, epoch u64each; later grants arrive asGRANTframes, and every shard request carries its shard’s epoch. A worker without it waits until every shard is free and gets them all under one epoch. - SHARED_
LOG - Log format 3: the server keeps one log for every shard. The worker sends
sections (
APPEND), gets cumulativeDURABLEpositions, and recovers withRECOVER_LOG; the segment requests are unused. No parameters. A server with a shared log refuses a worker that does not offer it. - SHARED_
MEMORY - Same-host shared memory over a Unix socket (
unix:/path?shm=1, see [crate::shm]): the lease frame carries the mapping and the server’s doorbell page as descriptors, and its parameter isring u64, the ring’s size. Log sections then go through the ring and durable positions come back in the mapping; everything else stays on the socket. The worker’s heartbeat in the mapping replacesPING. Granted withSHARD_LEASESandSHARED_LOGonly. - STORE_
OFFSETS - Every
STORE_APPEND_ATis answered withSTORE_APPENDEDcarrying the offset the server wrote at, or withIO_FAILED. The server refuses an append whose expected offset is not its store’s length and then stops the shard for the rest of the lease.
Functions§
- decode_
batch - decode_
section - decode_
sections - encode_
batch - encode_
section - The body of an
APPENDafter the head:first_lsn varint, last_lsn varint, records varint, section bytes. - encode_
sections - Sections in a
RECOVER_LOGanswer:first_lsn varint, count varint, byteseach. - head
- read_
head