Skip to content

Add PlatformHttpClient and PlatformBackend traits (EdgeZero PR6)#581

Open
prk-Jr wants to merge 29 commits intomainfrom
feature/edgezero-pr6-backend-http-client
Open

Add PlatformHttpClient and PlatformBackend traits (EdgeZero PR6)#581
prk-Jr wants to merge 29 commits intomainfrom
feature/edgezero-pr6-backend-http-client

Conversation

@prk-Jr
Copy link
Collaborator

@prk-Jr prk-Jr commented Mar 26, 2026

Summary

  • Introduce PlatformHttpClient trait with send(), send_async(), and select() for auction fan-out — a superset of EdgeZero's ProxyClient that covers the async/select paths not yet in EdgeZero upstream
  • Introduce PlatformBackend trait with predict_name() and ensure() to decouple backend registration from Fastly-specific APIs
  • Thread RuntimeServices through all proxy-layer handlers (IntegrationProxy::handle, endpoint handlers, proxy_request) so the HTTP client and backend are reachable without global state

Changes

File Change
platform/http.rs (new) PlatformHttpClient trait + PlatformHttpRequest, PlatformResponse, PlatformPendingRequest, PlatformSelectResult types
platform/backend.rs (new) PlatformBackend trait + PlatformBackendSpec
platform/types.rs RuntimeServices extended with http_client and backend fields
platform/test_support.rs StubHttpClient, StubBackend, build_services_with_http_client test helpers
integrations/registry.rs IntegrationProxy::handle + IntegrationRegistry::handle_proxy accept &RuntimeServices
All integration impls Pass _services through IntegrationProxy::handle
proxy.rs Migrate send path to services.http_client().send(); add ProxyRequestHeaders struct to stay under 7-arg limit; add proxy_request_calls_platform_http_client_send test
auction/orchestrator.rs Thread services through auction handler
platform.rs (Fastly adapter) FastlyPlatformHttpClient impl; document Body::Stream limitation with warning log
main.rs (Fastly adapter) Pass runtime_services to all route handlers

Closes

Closes #487

Test plan

  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • JS tests: cd crates/js/lib && npx vitest run
  • JS format: cd crates/js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses log macros (not println!)
  • New code has tests
  • No secrets or credentials committed

Notes for reviewer

This branch carries PRs 2–6 cumulatively (crate rename, platform traits, config store, secret store, HTTP client). The focused diff for this PR is the latest commit (571656c) plus the PR6-specific commits. The PlatformHttpClient::send_async and select methods intentionally return Err(Unsupported) in the Fastly adapter for now — the fan-out path in orchestrator.rs still uses fastly::http::request::select directly and will be migrated in a follow-up once EdgeZero adds upstream fan-out support (issues #147–148).

prk-Jr and others added 29 commits March 18, 2026 16:54
Rename crates/common → crates/trusted-server-core and crates/fastly →
crates/trusted-server-adapter-fastly following the EdgeZero naming
convention. Add EdgeZero workspace dependencies pinned to rev 170b74b.
Update all references across docs, CI workflows, scripts, agent files,
and configuration.
Introduces trusted-server-core::platform with PlatformConfigStore,
PlatformSecretStore, PlatformKvStore, PlatformBackend, PlatformHttpClient,
and PlatformGeo traits alongside ClientInfo, PlatformError, and
RuntimeServices. Wires the Fastly adapter implementations and threads
RuntimeServices into route_request. Moves GeoInfo to platform/types as
platform-neutral data and adds geo_from_fastly for field mapping.
- Defer KV store opening: replace early error return with a local
  UnavailableKvStore fallback so routes that do not need synthetic ID
  access succeed when the KV store is missing or temporarily unavailable
- Use ConfigStore::try_open + try_get and SecretStore::try_get throughout
  FastlyPlatformConfigStore and FastlyPlatformSecretStore to honour the
  Result contract instead of panicking on open/lookup failure
- Encapsulate RuntimeServices service fields as pub(crate) with public
  getter methods (config_store, secret_store, backend, http_client, geo)
  and a pub new() constructor; adapter updated to use new()
- Reference #487 in FastlyPlatformHttpClient stub (PR 6 implements it)
- Remove unused KvPage re-export from platform/mod.rs
- Use super::KvHandle shorthand in RuntimeServices::kv_handle()
- Split fastly_storage.rs into storage/{config_store,secret_store,api_client,mod}.rs
- Add PlatformConfigStore read path via FastlyPlatformConfigStore::get using ConfigStore::try_open/try_get
- Add PlatformError::NotImplemented variant; stub write methods on FastlyPlatformConfigStore and FastlyPlatformSecretStore
- Add StoreName/StoreId newtypes with From<String>, From<&str>, AsRef<str>
- Add UnavailableKvStore to core platform module
- Add RuntimeServicesBuilder replacing 7-arg constructor
- Migrate get_active_jwks and handle_trusted_server_discovery to use &RuntimeServices
- Update call sites in signing.rs, rotation.rs, main.rs
- Add success-path test for handle_trusted_server_discovery using StubJwksConfigStore
- Fix test_parse_cookies_to_jar_empty typo (was emtpy)
… layer

- Add PlatformHttpClient trait with send(), send_async(), and select() methods
- Add PlatformBackend trait with predict_name() and ensure() methods
- Add PlatformResponse wrapper around EdgeZero HTTP responses
- Add PlatformPendingRequest and PlatformSelectResult for auction fan-out
- Thread RuntimeServices through IntegrationProxy::handle(), IntegrationRegistry::handle_proxy(),
  and all first-party proxy endpoints so handlers can reach the HTTP client
- Add StubHttpClient and StubBackend test stubs with build_services_with_http_client helper
- Add proxy_request_calls_platform_http_client_send integration test
- Fix proxy_with_redirects to stay within 7-arg clippy limit via ProxyRequestHeaders struct
- Document Body::Stream limitation in edge_request_to_fastly with warning log
- Document intentional duplication of platform_response_to_fastly across proxy and orchestrator
- Remove spec file (promoted to plan + implementation)
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.

Backend + HTTP client traits

1 participant