Skip to main content

default_capacity

Function default_capacity 

Source
pub const fn default_capacity() -> NonZeroUsize
Expand description

How many keys a store holds when nobody has measured its workload.

A store for a tools/call result. It keeps the last this-many completed results so a client that retries after a dropped connection gets the recorded answer; once full it drops the oldest finished result to make room, and never a request still running. A retry older than the window runs again, which is the price of a server that keeps serving. The number is modest because the store is keyed by a peer-chosen request id. A deployment that knows its own rate replaces it — the capacity is a constructor argument on the adapter for exactly that reason.

A deployment that wants no ceiling sets a large capacity knowingly: the store is keyed by a peer-chosen request id, so an unbounded one is a memory exhaustion primitive.