frequenz-floss / frequenz-client-base-python

Base gRPC client
https://frequenz-floss.github.io/frequenz-client-base-python/
MIT License
0 stars 3 forks source link

Add a `BaseApiClient` class #56

Closed llucax closed 5 months ago

llucax commented 5 months ago

This class abstracts the common functionality of all the API clients. It provides a way to connect and disconnect from the server, provided as a URL, and a way to create the stubs to interact with the server.

It also provides an async context manager to make sure the connection is closed when the client is done.

We also add a new ClientNotConnected exception that is raised when performing operation on a client that is not connected to the server.

llucax commented 5 months ago

Actually marking as draft because it depends on #54.

llucax commented 5 months ago

54 merged, this is ready for review. I enabled auto-merge.

llucax commented 5 months ago

FYI, I'm planning to add support to easily wrap stub methods having automatic retry using retry strategies, and to have also an easy way to wrap streaming methods by having a list of GrpcStreamBroadcaster internally, which is something every client having streaming methods need to do. All of this in follow-up PRs, not this one, but just so you know where is this heading.