pub fn plan_upstream(
self_node_id: &str,
class: ReplicaClass,
requested: Option<&CascadeUpstream>,
) -> (UpstreamChoice, Option<CascadeRefusal>)Expand description
Decide where a node streams from, given its streaming class and an optionally-requested intermediate source.
The decision is total and side-effect-free:
- No requested intermediate →
UpstreamChoice::Primary, no refusal. - Requested, but the node is a voting member → refuse with
CascadeRefusal::VotingMemberDirectOnlyand fall back to the primary. - Requested, but the intermediate is this node itself → refuse with
CascadeRefusal::SelfReferenceand fall back to the primary. - Requested, node is an async read-replica, source is another node →
UpstreamChoice::Intermediate, no refusal.
Returning the refusal alongside the (safe) fallback choice lets the caller honour the connection immediately while still logging why a configured cascade did not take effect.