Skip to content

refactor(backends): make BackendList::backends crate-private - #1862

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
refactor/backendlist-backends-visibility
Oct 5, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
refactor/backendlist-backends-visibility

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Summary

Since #1856, a BackendList derives its sibling ring, shuffle-sharding representatives (shard_representative) and shared-address flag (shares_address) from its backend vector. Only add_backend/remove_backend refresh them, along with the Maglev table. The field was pub, so an embedder could push to, remove from or replace the vector and leave that derived state stale.

  • BackendList::backends is now pub(crate). The new pub fn backends(&self) -> &[Rc<RefCell<Backend>>] gives read-only access.
  • The only workspace reader outside the crate, lib/tests/udp_health_descriptor_exhaustion.rs, now calls the accessor.
  • Two doctests on the accessor check the guarantee. One reads the list through backends(). The other is identical except that it pushes to the field from outside the crate, and is marked compile_fail,E0616. Doctests compile as external crates. With the field set back to pub, the compile_fail doctest fails.
  • The length-mismatch guards from fix(load-balancing): give a shared address the share of one backend #1856 are kept. They still catch misuse inside the crate.
  • CHANGELOG: a "BREAKING (library API)" entry sits under Removed, next to the BackendMap::max_failures removal (refactor(backends): remove the unused BackendMap::max_failures field #1857), so both ship in the same release.

Other public fields (not changed)

  • load_balancing: assigning it directly skips the rebuild(&self.backends) that set_load_balancing_policy runs for Maglev. That is a separate invariant (the policy table, not the sibling state), so this PR leaves it alone.
  • next_id: nothing functional reads it. It only feeds debug assertions (check_invariants, add_backend postcondition).

Validation

  • cargo test -p sozu-lib -p sozu --no-default-features --features crypto-ring,opentelemetry,splice,simd: pass, including both new doctests
  • cargo check --all-targets for sozu-e2e, sozu-sim and fuzz; cargo check -p sozu-lib with crypto-aws-lc-rs and with crypto-openssl
  • cargo +1.93.1 clippy --workspace --all-targets … -D warnings, RUSTDOCFLAGS="-D warnings" cargo +1.93.1 doc --no-deps --locked -p sozu-lib, cargo +nightly fmt --all --check, check_doc_citations.py --base origin/main

Since #1856 a BackendList derives its sibling ring, shuffle-sharding
representatives and shared-address flag from the backend vector, and only
add_backend/remove_backend refresh them (and the Maglev table). The field
was public, so an embedder could push to or remove from the vector and
leave that state stale.

The field is now pub(crate) and BackendList::backends() returns a
read-only slice. The one external reader in the workspace, the
udp_health_descriptor_exhaustion integration test, uses the accessor.
Two doctests on the accessor hold the guarantee: one reads the list,
and an otherwise identical compile_fail,E0616 one pushes to the field
from outside the crate. The length-mismatch guards from #1856 stay for
in-crate misuse.

Library API break, recorded in the CHANGELOG beside the
BackendMap::max_failures removal (#1857).

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 60c8d51 into main Oct 5, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant