Repository navigation
refactor(backends): make BackendList::backends crate-private - #1862
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Since #1856, a
BackendListderives its sibling ring, shuffle-sharding representatives (shard_representative) and shared-address flag (shares_address) from its backend vector. Onlyadd_backend/remove_backendrefresh them, along with the Maglev table. The field waspub, so an embedder could push to, remove from or replace the vector and leave that derived state stale.BackendList::backendsis nowpub(crate). The newpub fn backends(&self) -> &[Rc<RefCell<Backend>>]gives read-only access.lib/tests/udp_health_descriptor_exhaustion.rs, now calls the accessor.backends(). The other is identical except that it pushes to the field from outside the crate, and is markedcompile_fail,E0616. Doctests compile as external crates. With the field set back topub, thecompile_faildoctest fails.BackendMap::max_failuresremoval (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 therebuild(&self.backends)thatset_load_balancing_policyruns 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_backendpostcondition).Validation
cargo test -p sozu-lib -p sozu --no-default-features --features crypto-ring,opentelemetry,splice,simd: pass, including both new doctestscargo check --all-targetsfor sozu-e2e, sozu-sim and fuzz;cargo check -p sozu-libwith crypto-aws-lc-rs and with crypto-opensslcargo +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