Skip to main content

Module proto

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§

req
resp

Structs§

Head
Header of every request after the kind byte: id, shard, epoch.

Constants§

DURABLE_PINS
A DURABLE flag: 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 IDLE entry’s flags: the shard still had work.
IDLE_EXPIRED
Bit 1 of an IDLE entry’s flags: the invocation’s budget ended.
INVOKED
An invoked worker (crate::invoke): HELLO carries, after the most shards to hold, the invocation’s ID u64. The server grants that invocation’s free shards at once, never more and never later (no standby), or refuses the connection. The lease parameter is remaining_ms u32, the invocation’s budget left. Granted with SHARD_LEASES only. The worker drains (DRAIN) and reports (IDLE) before it leaves.
LEASE_LIVENESS
The worker sends PING at least every interval while it holds the lease; the server revokes the lease after the timeout without traffic. The lease parameters are ping_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 with SHARD_LEASES. No parameters.
PAGED_RECOVERY
RECOVERY_PAGE
SHARD_LEASES
Shards are leased one at a time, each with its own epoch. HELLO carries, 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 u64 each; later grants arrive as GRANT frames, 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 cumulative DURABLE positions, and recovers with RECOVER_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 is ring 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 replaces PING. Granted with SHARD_LEASES and SHARED_LOG only.
STORE_OFFSETS
Every STORE_APPEND_AT is answered with STORE_APPENDED carrying the offset the server wrote at, or with IO_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 APPEND after the head: first_lsn varint, last_lsn varint, records varint, section bytes.
encode_sections
Sections in a RECOVER_LOG answer: first_lsn varint, count varint, bytes each.
head
read_head