chitralverma opened a new pull request, #9418:
URL: https://github.com/apache/opendal/pull/9418
# Which issue does this PR close?
Part of #9321 (tracker: #9320).
# Rationale for this change
Python does not expose the core `WriteOptions::expires` and
`content_language` fields. D#4931 asks for a per-write TTL on `redis` from
Python. A typical `content_language` use is a localized upload to S3:
`op.write("docs/fr-CA/index.html", html, content_language="fr-CA")`.
# What changes are included in this PR?
- `Operator.write`, `AsyncOperator.write`, `WriteKwargs`, and `open()` in
write modes take `content_language: str | None` and `expires: timedelta |
None`. `open()` in read mode raises `TypeError` for both, unless the value is
`None`.
- `expires` is a `datetime.timedelta`: options already take `datetime` for
timestamps, and the `default_ttl` config that `expires` overrides takes
`timedelta`. Presign keeps `expire_second: int`, and `presign_write` takes
neither field. Node.js (#9417) takes number seconds, like its presign, because
JavaScript has no standard duration type.
- The docstrings come from core. A new rule renders `Metadata::x` as
`Metadata.x`, the property of the `stat()` result.
- Tests: the frozen surface literals add both fields. Sync and async tests
check a stored `content_language`, an expired file, `ConfigInvalid` for zero,
and `Unsupported` without `write_with_expires`.
# Are there any user-facing changes?
- Both arguments are keyword-only. Without them, `write` and `open` behave
as before.
- `expires` raises `Unsupported` except on `redis` and `memcached`. `s3` and
`memory` store `content_language`. Other services ignore it, as core documents.
- A negative `timedelta` raises `ValueError` from `write()`. `open()` wraps
it in `TypeError`, as it does for every option.
Verified: each doc claim on `redis` 7.4, `memcached` 1.6, Silo S3, `memory`,
and `fs`, sync and async: TTL from commit, `default_ttl` override, round-up,
zero and too-large values, `Unsupported` at `open()`. Full suites on all five;
each new test fails under a mutation; `just stub-gen`, `just lint`, `just
test-typing`, Sphinx `-W -n`; `dev` tests; every `ci_odev.yml` generator with
`git diff --exit-code`.
Not verified: Redis cluster, TLS, Dragonfly, and kvrocks; AWS S3. PR CI runs
only the `Unsupported` path; nightly `redis` and `memcached` jobs run the
expiry path.
# Breaking changes
None.
# AI Usage Statement
- **Harness:** Claude Code via T3 Code | **Model:** Claude Opus 5.5 |
**Effort:** xhigh
- **Role:** Implemented the changes and tests, verified the docs on real
servers, and drafted this text. The author reviews every change and claim.
--
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]