Repository navigation
feat: public async transport - #474
Conversation
|
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 |
57aa024 to
54cafb8
Compare
There was a problem hiding this comment.
🟡 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
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 |
ced2eba to
3d7e4d9
Compare
sighphyre
left a comment
There was a problem hiding this comment.
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
| ) | ||
|
|
||
|
|
||
| def _check_transport( |
There was a problem hiding this comment.
I think this beast is now too big. Some thoughts here:
- 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
- I think it's actually lost the sync check, from the previous PR
- This is aggressively tying 3 unrelated sections of the application together - the requests import, the sync client validation and the async client validation
- 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
There was a problem hiding this comment.
yes this got a little messy, split it up now, kept the name
f7feec3 to
62ae943
Compare

async ounterpart of #473