Skip to content

feat: public async transport - #474

Merged
alexanto merged 5 commits into
mainfrom
feat/async-transport
Nov 11, 2026
Merged

alexanto merged 5 commits into
mainfrom
feat/async-transport

Conversation

@alexanto

@alexanto alexanto commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

async ounterpart of #473

@ppicom

ppicom commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Hi there! I haven't looked at the code, just at the number of LoC and files that changed. Have we considered splitting this PR in smaller ones? I know it's the top of the stack, a lot needs to happen for this one to get merged. But just throwing it out there to start thinking about whether it's possible

@gastonfournier gastonfournier moved this from New to In Progress in Issues and PRs Nov 6, 2026
@alexanto
alexanto force-pushed the feat/async-transport branch from 57aa024 to 54cafb8 Compare November 6, 2026 08:06
@alexanto
alexanto requested review from ppicom and a balanced review from Copilot November 6, 2026 09:18

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

Async transport validation rejects valid coroutine-returning methods wrapped by synchronous decorators, causing AsyncUnleashClient construction to fail before any request.

1 open issue
What changed in this PR

Extends public transport customization to AsyncUnleashClient, matching the synchronous client’s support for user-managed sessions and alternative HTTP libraries.

Changes:

  • Exposes async transports and adds constructor validation.
  • Adds custom aiohttp sessions, headers, and explicit resource ownership.
  • Expands tests, documentation, and examples for async transport usage.
File Description
UnleashClient/​transport.py Shares transport validation and authorization-header checks.
UnleashClient/​clients/​unleash_client.py Uses shared transport validation.
UnleashClient/​clients/​async_unleash_client.py Accepts and validates custom async transports.
UnleashClient/​_async_unleash_api_client.py Looks up response ETags case-insensitively.
UnleashClient/​_aiohttp_transport.py Supports user sessions, custom headers, and ownership-aware cleanup.
UnleashClient/​__init__.py Exports async transport interfaces and implementation.
tests/​unit_tests/​test_aiohttp_transport.py Tests session ownership, headers, and response handling.
tests/​unit_tests/​clients/​test_async_unleash_client_transport.py Tests transport integration, validation, and examples.
README.md Documents async transport configuration and lifecycle.
examples/​httpx_async_transport.py Demonstrates an httpx-backed async transport.
examples/​fake_async_transport.py Demonstrates async testing without a server.
CHANGELOG.md Records public async transport support.

Review effort: Balanced

Comment thread UnleashClient/transport.py Resolved
@alexanto

alexanto commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Hi there! I haven't looked at the code, just at the number of LoC and files that changed. Have we considered splitting this PR in smaller ones? I know it's the top of the stack, a lot needs to happen for this one to get merged. But just throwing it out there to start thinking about whether it's possible

i rebased it so it appears much smaller and the actual code is change is ~200 lines, the rest is just tests and changelog, so i hope it is not that horrible now

@alexanto
alexanto force-pushed the feat/async-transport branch from ced2eba to 3d7e4d9 Compare November 6, 2026 13:04

@sighphyre sighphyre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this has come together nicely, I think we should rethink the check transport functions responsibilities and coupling a little but other than that, it looks sound

Comment thread UnleashClient/transport.py Outdated
)


def _check_transport(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this beast is now too big. Some thoughts here:

  1. This is doing 3 things, first it's checking requests stuff, second its checking async stuff if it was called by the async paths, third it should be checking sync stuff if it was called by the sync paths
  2. I think it's actually lost the sync check, from the previous PR
  3. This is aggressively tying 3 unrelated sections of the application together - the requests import, the sync client validation and the async client validation
  4. 5 parameters is leaning on the side of too many parameters, especially when we pass boolean flags to target behavior is a sign that the function should be multiple functions

Sooo... after that whole essay, I would suggest not moving this here. Leave this function in the sync client, don't care what you call it. Have that function check that we have an synchronous execute method. If you really want, include the check for requests. Then make another function in the async client, can be the same name, don't care. Have that function check that we have a async execute - we can leave the requests check off that probably

Think it's one of those places where a little copying is better than a lot of coupling

@alexanto alexanto Nov 11, 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.

yes this got a little messy, split it up now, kept the name

@github-project-automation github-project-automation Bot moved this from In Progress to Approved PRs in Issues and PRs Nov 10, 2026
Base automatically changed from feat/public-sync-transport to main November 11, 2026 12:45
@alexanto
alexanto force-pushed the feat/async-transport branch from f7feec3 to 62ae943 Compare November 11, 2026 12:53
@alexanto
alexanto merged commit e4acab7 into main Nov 11, 2026
8 checks passed
@alexanto
alexanto deleted the feat/async-transport branch November 11, 2026 14:03
@github-project-automation github-project-automation Bot moved this from Approved PRs to Done in Issues and PRs Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants