Skip to content

Replace once_cell with standard library primitives - #956

Open
ting-hong-shieh wants to merge 1 commit into
cloudflare:mainfrom
ting-hong-shieh:refactor/replace-once-cell
Open

Replace once_cell with standard library primitives#956
ting-hong-shieh wants to merge 1 commit into
cloudflare:mainfrom
ting-hong-shieh:refactor/replace-once-cell

Conversation

@ting-hong-shieh

Copy link
Copy Markdown

Closes #721.

This is a current-main replacement for #732 and #735, which now conflict with the base branch.

Summary

  • Replace Pingora's direct uses of once_cell::sync::Lazy and OnceCell with std::sync::LazyLock and OnceLock.
  • Preserve concurrent runtime initialization by using OnceLock::set followed by get, and add a test that initializes a no-steal runtime from four threads.
  • Update examples and user guides to use the standard-library types, then remove the direct once_cell declarations from the workspace crates.

once_cell can still appear transitively through third-party crates; this change removes Pingora's direct dependency on it.

Testing

  • cargo fmt --all -- --check
  • cargo +1.85.0 check --workspace --exclude pingora-foundations
  • cargo check --workspace
  • cargo test -p pingora-runtime test_no_steal_runtime_concurrent_initialization -- --nocapture
  • cargo test --doc
  • cargo clippy --all-targets --all -- --allow=unknown-lints --deny=warnings
  • cargo machete

The full library, binary, and integration test command passed all targets that do not require OpenResty. The local host does not have OpenResty, so pingora-proxy's test_basic and test_upstream targets could not start their mock origin; the repository CI installs OpenResty before running them.

@ting-hong-shieh
ting-hong-shieh marked this pull request as ready for review August 13, 2026 11:35
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.

Replace once_cell dependency with std LazyLock and OnceLock

1 participant