Skip to content

feat: public sync transport - #473

Open
alexanto wants to merge 3 commits into
refactor/retry-policyfrom
feat/public-sync-transport
Open

alexanto wants to merge 3 commits into
refactor/retry-policyfrom
feat/public-sync-transport

Conversation

@alexanto

@alexanto alexanto commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

in this PR, I start doing what I set out to really do in the first place

made the generic transport public in the sync client, so users can now bring their own trasport implementation and use a different http library other than requests or they can inject a session only depending their needs. haven't removed HttpOptions yet, but clearly doesn't sit well with this redesign, coming shortly.

@alexanto
alexanto force-pushed the feat/public-sync-transport branch from 3df6c8c to 2ef586e Compare November 5, 2026 13:28
@gastonfournier gastonfournier moved this from New to In Progress in Issues and PRs Nov 6, 2026
@alexanto
alexanto requested review from ppicom and a balanced review from Copilot November 6, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Valid falsey custom transports are silently replaced with the default, causing unintended real HTTP requests, while custom transport users also lose control over the SDK retry budget.

2 open issues
What changed in this PR

This PR exposes the synchronous client's HTTP transport API, allowing callers to supply a configured requests.Session or use another HTTP library.

Changes:

  • Publishes transport types and adds validated transport= injection.
  • Adds session reuse, custom transport headers, and case-insensitive response-header lookup.
  • Adds documentation, runnable examples, and transport integration tests.
File Description
UnleashClient/​transport.py Publishes transport interfaces and configurable requests transport.
UnleashClient/​clients/​unleash_client.py Validates and forwards custom transports.
UnleashClient/​_unleash_api_client.py Uses public transport types and case-insensitive ETag lookup.
UnleashClient/​_transport.py Removes the former private transport module.
UnleashClient/​_retry.py Imports public transport types.
UnleashClient/​_async_unleash_api_client.py Updates transport imports.
UnleashClient/​_aiohttp_transport.py Updates request and response imports.
UnleashClient/​__init__.py Exports the public sync transport API.
tests/​unit_tests/​test_unleash_api_client.py Tests case-insensitive response headers.
tests/​unit_tests/​test_transport.py Tests sessions, headers, timeouts, and retry warnings.
tests/​unit_tests/​test_retry.py Updates transport imports.
tests/​unit_tests/​test_async_unleash_api_client.py Updates transport imports.
tests/​unit_tests/​test_aiohttp_transport.py Updates transport imports.
tests/​unit_tests/​clients/​test_unleash_client_transport.py Tests transport injection, validation, and examples.
requirements.txt Adds httpx for testing.
README.md Documents custom transports and ownership requirements.
pyproject.toml Excludes examples from package discovery.
examples/​httpx_transport.py Demonstrates an httpx-backed transport.
examples/​fake_transport.py Demonstrates server-free feature testing.
CHANGELOG.md Announces public sync transport support.

Review effort: Balanced

Comment on lines +105 to +106
built from ``config.http``. A transport passed in is never
closed: whoever created it closes it.

@alexanto alexanto Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems rare but possibly legit to me, so pushed a fix

Comment on lines +63 to +67
if http is not None:
raise ValueError(
"Pass either http or transport, not both. Set headers and the "
"timeout on the transport: RequestsTransport(headers=..., timeout=...)."
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is opinionated, i think default SDK retries should not be configurable, if we need the disable retries option we can add later as non-breaking

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants