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

Make `GrpcStreamBroadcaster` compatible with both `grpcio` and `grpclib` #49

Closed llucax closed 6 months ago

llucax commented 6 months ago

With this change GrpcStreamBroadcaster can be used with both grpcio and grpclib implementations of gRPC.

This is achieved by using AsyncIterator instead of grpc.aio.UnaryStreamCall in the stream_method parameter of GrpcStreamBroadcaster to make it more generic, and catching exceptions from both grpcio and grpclib in the async for loop.

To deal with any of the libraries being installed, a new module is added to handles exceptions from both libraries, by conditionally importing the exception and provide a dummy one if the library is not installed.

Now both grpcio and grpclib are optional, and can be installed using frequenz-client-base[grpcio] or frequenz-client-base[grpclib] respectively.

We also add some tests for GrpcStreamBroadcaster.

llucax commented 6 months ago

Based on #48.

llucax commented 6 months ago

Updated. Will fix up before merging.

llucax commented 6 months ago

Updated.

llucax commented 6 months ago

Enabled auto-merge.

llucax commented 6 months ago

The good news is the merge queue checks now works correctly, the bad news is I forgot 2 fixes need to be applied to fix the CI, so this PR depends now on this PR to be merged:

llucax commented 6 months ago

Rebased, it needs a new approval.