Repository navigation
feat: emit FETCH_COMPLETED after every feature fetch - #456
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
sighphyre
left a comment
There was a problem hiding this comment.
I think this is good. Want to wait for some feedback from others before I merge though
|
I think the new event should also be documented in the readme |
Fair, but we're halfway through migrating docs to here: https://docs.getunleash.io/sdks/python I think let's leave it in this PR, I can open a PR for that with the docs team (and maybe even clean up the README here to be what we agreed on with Documentation before they realize I haven't done that and they come for me) |
from my view this is a sane addition, but lets wait for what the others think
|
@Elyahou thanks for the work on this PR, really appreciated. I left a question about including the http code in the event itself. The rest of it is looking nice! |
Thanks ! I replied to your comment |
The event no longer carries an HTTP status code. Instead the status says what a listener should do about it: UNAUTHORIZED (401/403, won't recover on its own), RATE_LIMITED (429, back off), UNAVAILABLE (5xx after retries, timeout or no response) and INVALID_RESPONSE (empty 200 or any other status) replace FAILED. The code is read in one place, in the transport, so the event stays free of HTTP. The sync Retry goes back to raise_on_status: a 5xx after retries is UNAVAILABLE whether or not the last response is handed back.
…d-event # Conflicts: # CHANGELOG.md
9741d2e to
2b2e594
Compare
…d-event # Conflicts: # CHANGELOG.md # UnleashClient/_async_transport.py # tests/unit_tests/test_async_transport.py # tests/unit_tests/test_transport.py
ppicom
left a comment
There was a problem hiding this comment.
Looks good, I think FAILED got renamed to UNAVAILABLE again. If we sort that, we can merge 🚀

Why the change
A failed or unchanged fetch emits no event today (only
FETCHED, for a changed payload, andREADY), so an application that wants to count fetch failures or track how old its definitions are has to patchrequestsitself; this adds aFETCH_COMPLETEDevent after every fetch, like the Java SDK'stogglesFetched(ClientFeaturesResponse).Special things to note
FETCHEDis unchanged and still fires only for a changed payload, so existing callbacks see the same events plus the new one.FetchStatusthat says what a listener should do about it.FETCHED/READY. It covers polling only; the streaming connector doesn't fetch, so it doesn't emit it.Change outline
Counting fetch failures and tracking when definitions were last confirmed, through the existing
event_callback:Tests cover each status on both transports (200, 304, 401, 403, 429, a 500 after retries, 503, an unexpected 202, an empty 200, no response, and on the async one a body that times out), a listener that raises, and both clients delivering the event to their
event_callback.