Skip to content
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

Clear release notes #94

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 6 additions & 38 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,16 @@

## Summary

This release improves the `BaseApiClient` interface and introduces HTTP2 keep-alive, among other changes.
<!-- Here goes a general summary of what this release is about -->

## Upgrading

- `GrpcStreamBroadcaster` now takes a `AsyncIterable` instead of a `AsyncIterator` as the `stream_method`. This is to match the type of streaming methods generated by `grpc`, so no conversion to an `AsyncIterator` is needed.
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->

- `GrpcStreamBroadcaster` no longer tries to reconnect when a server closes a connection. This behaviour can be overridden by passing `retry_on_exhausted_stream=True` when constructing `GrpcStreamBroadcaster` instances.

- gRPC URLs don't have a default port anymore, unless a default is set via `ChannelOptions`. If you want to set a default port for URLs, please pass custom `ChannelOptions` as `defaults` to `parse_grpc_uri` or as `channel_defaults` to `BaseApiClient`.

* The `ExponentialBackoff` and `LinearBackoff` classes now require keyword arguments for their constructor. This change was made to make the classes easier to use and to avoid confusion with the order of the arguments.

- HTTP2 keep-alive is now enabled by default, with an interval of 60 seconds between pings, and a 20 second timeout for responses from the service. These values are configurable and may be updated based on specific requirements.

* The `BaseApiClient` class is not generic anymore, and doesn't take a function to create the stub. Instead, subclasses should create their own stub right after calling the parent constructor. This enables subclasses to cast the stub to the generated `XxxAsyncStub` class, which have proper `async` type hints. To convert you client:

```python
# Old
from my_service_pb2_grpc import MyServiceStub
class MyApiClient(BaseApiClient[MyServiceStub]):
def __init__(self, server_url: str, *, ...) -> None:
super().__init__(server_url, MyServiceStub, ...)
...

# New
from typing import cast
from my_service_pb2_grpc import MyServiceStub, MyServiceAsyncStub
class MyApiClient(BaseApiClient):
def __init__(self, server_url: str, *, ...) -> None:
super().__init__(server_url, connect=connect)
self._stub = cast(MyServiceAsyncStub, MyServiceStub(self.channel))
...

@property
def stub(self) -> MyServiceAsyncStub:
if self._channel is None:
raise ClientNotConnected(server_url=self.server_url, operation="stub")
return self._stub
```
## New Features

After this, you should be able to remove a lot of `cast`s or `type: ignore` from the code when calling the stub `async` methods.
<!-- Here goes the main new features and examples or instructions on how to use them -->

## New Features
## Bug Fixes

- Added support for HTTP2 keep-alive.
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
Loading