1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! SRV-043 R1: one mapping from beamr's readiness refusals to the server's
//! error, shared by the TCP and WebSocket connection processes for register and
//! rearm alike.
use beamr::scheduler::ReadinessError;
use crate::ServerError;
/// Which readiness call beamr refused.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum ReadinessCall {
/// The connection's one registration.
Register,
/// A rearm of that registration.
Rearm,
}
/// The server's error for `call`, refused by beamr with `error` for the
/// connection process `pid`: the server's stop as
/// [`ServerError::ReadinessClosedByStop`], every other refusal as
/// [`ServerError::ListenerAccept`] with the call named.
pub(super) fn readiness_refusal(
pid: u64,
call: ReadinessCall,
error: &ReadinessError,
) -> ServerError {
// beamr refuses with TeardownInProgress once the scheduler's teardown has
// closed readiness admission: the server's own stop, not a fault.
if *error == ReadinessError::TeardownInProgress {
return ServerError::ReadinessClosedByStop { pid };
}
let verb = match call {
ReadinessCall::Register => "register",
ReadinessCall::Rearm => "rearm",
};
ServerError::ListenerAccept {
message: format!("failed to {verb} connection readiness: {error}"),
}
}