-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for async methods #65
Conversation
…est for pytest/unittest compatability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contributions!
IMO the async API make sense, unfortunately I don't know too much about Python and if there are different libraries to use here?
For example, is asyncio
an alternative approach?
Please address the comment about OpenFeature stuff.
Other than that, there seems to be some opportunity to refactor to reuse some of the code in the evalate
and resolve
functions... I could live with that but the fruit is pretty low hanging.
confidence/openfeature_provider.py
Outdated
@@ -121,6 +121,24 @@ def resolve_boolean_details( | |||
flag_metadata=details.flag_metadata, | |||
) | |||
|
|||
async def resolve_boolean_details_async( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpenFeature provider should not be used on it's own but rather together with the OpenFeature SDK so I would revert the changes in this class (and the test).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright this has been removed, I'll look into adding the feature into OpenFeature SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked about it in their slack yesterday and was pointed to this issue. Federico that has commented on that issue is one of the main contributors to the OpenFeature Python SDK and he seems positive 👍
httpx and aiohttp are built on top of asyncio and tend to be the go-to options for async requests due to their robustness. Implementing requests with asyncio directly tends to be pretty messy and error prone.
This article has a good comparison. Something to consider is the default configuration on the client e.g. timeout default is 5 seconds with httpx. Either option is appropriate for the use case and there should be negligible differences in speed (not tested for the use case). If there's a preference, switching is straight forward.
Happy to do this change, I was initially avoid refactoring. It's a common issue in python is supporting sync/async you end up with large chunks of forked code. |
Introduce async support using httpx.