Crate fedimint_portalloc

source
Expand description

A library for cooperative port allocation between multiple processes.

Fedimint tests in many places need to allocate ranges of unused ports for Federations and other software under tests, without being able to bind them beforehand.

We used to mitigate that using a global per-process atomic counter, as as simple port allocation mechanism. But this does not prevent conflicts between different processes.

Normally this would prevent us from running multiple tests at the same time, which also makes it impossible to use cargo nextest.

This library keeps track of allocated ports (with an expiration timeout) in a shared file, protected by an advisory fs lock, and uses bind to make sure a given port is actually free

Modulesยง

Functionsยง