kubernetes_asyncio
kubernetes_asyncio copied to clipboard
dynamic.DynamicClient
Any plan to have dynamic.DynamicClient ?
Yes, it's on my TODO list.
@tomplus if this can be a port of the existing code in the sync client I'd be glad to work on it.
@bobh66 Thanks! You can port code from the sync client and make it asynchronous. Let me know if you have any questions.
I think the main question is how to handle the async initialization requirements of the Discoverer and DynamicClient classes? They both need to do async operations on class creation, so some sort of factory method is needed, like:
class Discoverer:
......
async def _ainit(self):
await self.__init_cache()
@classmethod
async def create(cls, client, cache_file=None):
self = cls(client=client, cache_file=cache_file)
await self._ainit()
return self
and then the class creation becomes:
self.__discoverer = discoverer.create(self, self.cache_file)
Is there a better pattern or is this an acceptable API for the classes?
Thanks
I like your solution, you can implemented it in this way :+1:
I was able to come up with a better solution using the __await__ magic method so that the DynamicClient and Discoverer objects can be await'ed directly and a separate create method is not needed.
These changes are ready to be pushed I'm just waiting on some process overhead from my employer and then I'll create a PR.
@bobh66 Thanks for this! Looking forward to using it.