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

Make RequestConcurrencyController public #2278

Merged
merged 5 commits into from
Jul 29, 2022

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Jul 18, 2022

Motivation:

Users can not wrap connections inside the LoadBalancer or
HttpLoadBalancerFactory because RequestConcurrencyController API is
internal.

Modifications:

  • Move RequestConcurrencyController and
    ReservableRequestConcurrencyController from client-api-internal to
    client-api;
  • LoadBalancedConnection now extends
    ReservableRequestConcurrencyController;
  • FilterableStreamingHttpLoadBalancedConnection now extends
    ReservedStreamingHttpConnection;
  • Introduce HttpLoadBalancerFactory#toLoadBalancedConnection overload
    that also accepts ReservableRequestConcurrencyController and ContextMap;
  • Deprecated HttpLoadBalancerFactory#toLoadBalancedConnection(FilterableStreamingHttpConnection);
  • Add DefaultFilterableStreamingHttpLoadBalancedConnection that helps
    users combine FilterableStreamingHttpConnection,
    ReservableRequestConcurrencyController and ScoreSupplier or do
    wrapping;
  • Remove LoadBalancedStreamingHttpConnection as it's not required
    anymore;
  • Update internals to use new API;

Result:

Users can wrap the FilterableStreamingHttpLoadBalancedConnection
inside their LoadBalancer or HttpLoadBalancerFactory implementations.

Motivation:

Users can not wrap connections inside the `LoadBalancer` or
`HttpLoadBalancerFactory` because `RequestConcurrencyController` API is
internal.

Modifications:

- Move `RequestConcurrencyController` and
`ReservableRequestConcurrencyController` from `client-api-internal` to
`client-api`;
- `FilterableStreamingHttpLoadBalancedConnection` now extends
`ReservableRequestConcurrencyController` and
`ReservedStreamingHttpConnection`;
- Introduce `HttpLoadBalancerFactory#toLoadBalancedConnection` overload
that also accepts `ReservableRequestConcurrencyController`, deprecate
pre-existing overload;
- Add `DefaultFilterableStreamingHttpLoadBalancedConnection` that helps
users combine `FilterableStreamingHttpConnection`,
`ReservableRequestConcurrencyController` and `ScoreSupplier` or do
wrapping;
- Remove `LoadBalancedStreamingHttpConnection` as it's not required
anymore;
- Update internals to use new API;

Result:

Users can wrap the `FilterableStreamingHttpLoadBalancedConnection`
inside their `LoadBalancer` or `HttpLoadBalancerFactory` implementations.
FilterableStreamingHttpConnection connection);
default FilterableStreamingHttpLoadBalancedConnection toLoadBalancedConnection(
FilterableStreamingHttpConnection connection,
ReservableRequestConcurrencyController concurrencyController) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to discussions here. For now, I tried to keep pre-existing assumption that the HttpLoadBalancerFactory knows how to implement score() for the passed connection. In practice, the score() implementation may not be self-sufficient and can rely on external information from the LB or CF. Since we already pass the ContextMap through request -> selectConnection -> newConnection chain, we can add it here as a 3rd nullable argument too to preserve that context info. LMK WDYT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with @tkountis offline and agreed to add the context as the 3rd arg. It may be helpful to propagate information between layers without API changes in the future. Also, consistency with selectConnection and newConnection.

@idelpivnitskiy
Copy link
Member Author

@tkountis your offline comments addressed, please have another look

@tkountis
Copy link
Contributor

Nice work.

@idelpivnitskiy idelpivnitskiy merged commit 6e47753 into apple:main Jul 29, 2022
@idelpivnitskiy idelpivnitskiy deleted the concurrency-controller branch July 29, 2022 20:06
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Aug 3, 2022
…le#2278

Motivation:

apple#2278 moved `RequestConcurrencyController` and
`ReservableRequestConcurrencyController` from `client-api-internal` to
`client-api` module. This is an API incompatible change for 0.42.x.
Also, it removed
`DefaultHttpLoadBalancerFactory#toLoadBalancedConnection` impl, this
is a binary incompatible change.

Modifications:

- Restore `io.servicetalk.client.api.internal.RequestConcurrencyController`
and `io.servicetalk.client.api.internal.ReservableRequestConcurrencyController`
interfaces and all references to them in `client-api-internal` module;
- Create a pkg-private copy of `ReservableRequestConcurrencyControllers`
inside `http-netty` module that targets public
`io.servicetalk.client.api.ReservableRequestConcurrencyController`;
- Copy tests for `ReservableRequestConcurrencyControllers`;
- Create a pkg-private copy of
`io.servicetalk.client.api.internal.IgnoreConsumedEvent` in `http-netty`
module;
- Deprecate all classes and interfaces in `client-api-internal` module;
- Remove unnecessary references to `servicetalk-client-api-internal`
dependency in modules that don't actually depend on it;

Result:

1. The next 0.42.14 release will be backward compatible with 0.42.13.
2. The whole `servicetalk-client-api-internal` module is deprecated now
and can be removed in the future releases.

Signed-off-by: Idel Pivnitskiy <idel.pivnitskiy@apple.com>
idelpivnitskiy added a commit that referenced this pull request Aug 4, 2022
… (#2306)

Motivation:

#2278 moved `RequestConcurrencyController` and
`ReservableRequestConcurrencyController` from `client-api-internal` to
`client-api` module. This is an API incompatible change for 0.42.x.
Also, it removed
`DefaultHttpLoadBalancerFactory#toLoadBalancedConnection` impl, this
is a binary incompatible change.

Modifications:

- Restore `io.servicetalk.client.api.internal.RequestConcurrencyController`
and `io.servicetalk.client.api.internal.ReservableRequestConcurrencyController`
interfaces and all references to them in `client-api-internal` module;
- Create a pkg-private copy of `ReservableRequestConcurrencyControllers`
inside `http-netty` module that targets public
`io.servicetalk.client.api.ReservableRequestConcurrencyController`;
- Copy tests for `ReservableRequestConcurrencyControllers`;
- Create a pkg-private copy of
`io.servicetalk.client.api.internal.IgnoreConsumedEvent` in `http-netty`
module;
- Deprecate all classes and interfaces in `client-api-internal` module;
- Remove unnecessary references to `servicetalk-client-api-internal`
dependency in modules that don't actually depend on it;

Result:

1. The next 0.42.14 release will be backward compatible with 0.42.13.
2. The whole `servicetalk-client-api-internal` module is deprecated now
and can be removed in future releases.
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Aug 30, 2022
Motivation:

apple#2278 added a new connection wrapper
`DefaultFilterableStreamingHttpLoadBalancedConnection` that does not
implement `toString()`. It hides the channel id in RRLB logs.

Modifications:

- Implement `toString()` for
`DefaultFilterableStreamingHttpLoadBalancedConnection` in
`HttpLoadBalancerFactory` and `DefaultHttpLoadBalancerFactory`;
- Make `AbstractStreamingHttpConnection#toString()` final;

Result:

RRLB logs include channel id.
idelpivnitskiy added a commit that referenced this pull request Sep 8, 2022
Motivation:

#2278 added a new connection wrapper
`DefaultFilterableStreamingHttpLoadBalancedConnection` that does not
implement `toString()`. It hides the channel id in RRLB logs.

Modifications:

- Implement `toString()` for
`DefaultFilterableStreamingHttpLoadBalancedConnection` in
`HttpLoadBalancerFactory` and `DefaultHttpLoadBalancerFactory`;
- Make `AbstractStreamingHttpConnection#toString()` final;

Result:

RRLB logs include channel id.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants