Xuanwo opened a new pull request, #8931:
URL: https://github.com/apache/opendal/pull/8931
# Which issue does this PR close?
Part of #8880.
# Rationale for this change
HTTP-backed services previously called `Signer::with_context` on every
request to attach the current `OperationContext::http_transport()`. Rebinding
the signing context per request adds per-operation overhead and is fragile with
reqsign's signer/cache ownership semantics across `reqsign 0.20.x` and `0.21`.
In S3, `AssumeRoleCredentialProvider` also hardcoded
`HttpTransporter::default()` at build time instead of honoring the transport
carried in `OperationContext`.
Caching signers per `HttpTransporter` identity keeps `raw::Service` and
`raw::Layer` unchanged, avoids strong reference cycles via weak transport
handles, and preserves transport isolation when callers swap or layer HTTP
transports on an `Operator`.
# What changes are included in this PR?
- **`opendal-core`**:
- Added `pub(crate)` transport identity and weak-handle helpers on
`HttpTransporter`.
- Added `raw::HttpTransportCache<V>` and `raw::WeakHttpTransporter`
(implementing `reqsign_core::HttpSend` under `feature = "reqsign"`), keyed by
the transport `Arc`'s thin data pointer address, using lock-free initialization
with `std::sync::RwLock`, double-checked insertion, pruning of dropped
transports before insert, and dropping evicted values outside the lock.
- Added unit tests covering same-transport reuse, distinct-transport and
ZST isolation, dead-entry pruning without reference cycles,
`WeakHttpTransporter::http_send` (alive and dropped), and concurrent/reentrant
initialization.
- **`opendal-service-s3`**:
- Introduced `S3SignerSpec`, `S3AssumeRoleConfig`, and
`HttpTransportCache<S3Signers>` in `S3Core`, constructing fresh `Signer`
instances per transport (including `AssumeRoleCredentialProvider`'s STS signer
and `S3ExpressSessionProvider`).
- Removed the hardcoded `HttpTransporter::default()` from `AssumeRole` STS
signing so STS calls use `OperationContext::http_transport()`.
- Added unit tests verifying transport-scoped signer reuse,
cross-transport isolation and eviction, and `AssumeRole` STS transport
propagation.
- **`opendal-service-gcs-grpc`** and **`opendal-service-cos`**:
- Replaced per-request `Signer::with_context` with
`HttpTransportCache<Signer<Credential>>` backed by shared `sign_ctx`,
credential provider, and request signer state.
Remaining reqsign-backed services (`gcs`, `oss`, `tos`, `obs`, `azblob`,
`azdls`, `azfile`, `ghac`) will be migrated in a follow-up PR to avoid
conflicting with in-flight service PRs.
# Are there any user-facing changes?
- `opendal_core::raw::HttpTransportCache` and
`opendal_core::raw::WeakHttpTransporter` are exposed for service
implementations.
- S3 `AssumeRole` STS requests now use the HTTP transport configured on
`OperationContext` rather than always falling back to
`HttpTransporter::default()`.
- No changes to `Operator`, `raw::Service`, or `raw::Layer`.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: high
- Role: Implemented `raw::HttpTransportCache` and
`raw::WeakHttpTransporter`, migrated signer caching in `s3`, `gcs-grpc`, and
`cos`, and added unit tests following the approved design for #8880.
Verification covered local unit tests, clippy, doctests, rustdoc, and
`wasm32-unknown-unknown` compilation; no live cloud service integration tests
were run.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]