Caducus
Caducus (lat.): perishable
Bounded async channel with item expiry. Supports SPSC and MPSC operating modes. Requires Tokio.
Author intended use case is for deterministic memory footprint systems with set timeouts and error handling at each intelligent module. This module is not trying to be intelligent, it just offers the receiver the data until it expires and gives it back to the sender if it is spoilt.
The author hopes others find additional use cases.
- Aims for high throughput
- Expired items drained on expiry (not on next receiver pop)
- Sender is responsible for handling returned items (no expiry/shutdown retries)
- Aims to be panick free and panick resistant
Install
Example
use Duration;
use MpscBuilder;
async
Layers
- Sender/Receiver public APIs
- Reclaimer expiry tracker
- Concurrency layer
- Ring buffer layer
Documentation
API reference: https://docs.rs/caducus.
Architecture and design notes:
docs/caducus.md— architecture overview, layering, public API, conservation invariantdocs/ring-buffer.md— storage layer: structure, operations, resize, mode-aware push/popdocs/concurrency.md— concurrency layer: DrainMode, two Notify handles, send/drain pathsdocs/reclaimer.md— reclaimer task, try_receive, expiry/shutdown reporting, unwind isolationdocs/sender.md— builders, send patterns, clone semantics, sender drop, set_channelsdocs/receiver.md— receive behaviour, deadline-based API, expired-head fallbackdocs/performance.md— performance test scenarios and conservation validation
Use of Artificial Intelligence
OpenAI Codex and Anthopic Claude Code were used as coding agents and code reviewers.
Google Gemini CLI was used as a code reviewer.
License
Licensed under the Apache License, Version 2.0 (LICENSE or https://www.apache.org/licenses/LICENSE-2.0).