code
Clone this repository
https://tangled.org/gdiazlo.tngl.sh/swim
git@tangled.org:gdiazlo.tngl.sh/swim
For self-hosted knots, clone URLs may differ based on your setup.
Core library implementation with 11 modules:
- types.ml/mli: Core immutable types (node_id, incarnation, member_state, protocol_msg, packet, config, env, stats)
- codec.ml: Zero-copy binary encoding/decoding with magic bytes, version, message tags
- crypto.ml: AES-256-GCM encryption using Mirage_crypto
- buffer_pool.ml/mli: Lock-free buffer pool using Kcas_data.Queue + Eio.Semaphore
- protocol_pure.ml/mli: Pure SWIM state transitions (handle_alive/suspect/dead, suspicion_timeout, etc)
- membership.ml/mli: Kcas-based member table with Kcas_data.Hashtbl
- dissemination.ml/mli: Broadcast queue with transmit counting and message invalidation
- pending_acks.ml/mli: Ack tracking with Eio.Promise for async waiting
- transport.ml: UDP/TCP networking with Eio.Net
- protocol.ml: Main protocol loop with message handlers and probe cycles
- swim.ml: Public API with Cluster module
Design constraints followed:
- Eio only (no Lwt/Async/Mutex/Condition)
- All coordination via kcas (no locks)
- Result types for expected errors (no exceptions)
- Zero-copy buffer management