Skip to content

Commit

Permalink
Revert backward incompatible changes (api & binary) introduced in #2278
Browse files Browse the repository at this point in the history
… (#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.
  • Loading branch information
idelpivnitskiy authored Aug 4, 2022
1 parent c7375c4 commit 5cfe9c4
Show file tree
Hide file tree
Showing 28 changed files with 579 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.ConsumableEvent;
import io.servicetalk.client.api.RequestConcurrencyController;
import io.servicetalk.concurrent.Cancellable;
import io.servicetalk.concurrent.CompletableSource;
import io.servicetalk.concurrent.api.Completable;
Expand All @@ -28,6 +27,7 @@
import static io.servicetalk.concurrent.api.SourceAdapters.toSource;
import static java.util.concurrent.atomic.AtomicIntegerFieldUpdater.newUpdater;

@Deprecated // FIXME: 0.43 - remove deprecated class
abstract class AbstractRequestConcurrencyController implements RequestConcurrencyController {
private static final AtomicIntegerFieldUpdater<AbstractRequestConcurrencyController>
pendingRequestsUpdater = newUpdater(AbstractRequestConcurrencyController.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.ConsumableEvent;
import io.servicetalk.client.api.ReservableRequestConcurrencyController;
import io.servicetalk.concurrent.Cancellable;
import io.servicetalk.concurrent.CompletableSource.Subscriber;
import io.servicetalk.concurrent.api.Completable;
Expand All @@ -31,6 +30,7 @@
import static io.servicetalk.concurrent.internal.SubscriberUtils.handleExceptionFromOnSubscribe;
import static java.util.concurrent.atomic.AtomicIntegerFieldUpdater.newUpdater;

@Deprecated // FIXME: 0.43 - remove deprecated class
abstract class AbstractReservableRequestConcurrencyController implements ReservableRequestConcurrencyController {
private static final AtomicIntegerFieldUpdater<AbstractReservableRequestConcurrencyController>
pendingRequestsUpdater = newUpdater(AbstractReservableRequestConcurrencyController.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
* A {@link ConsumableEvent} which ignores {@link #eventConsumed()}.
*
* @param <T> The type of event.
* @deprecated This class is not used by ServiceTalk internal code anymore and will be removed in the future releases.
* If you depend on it, consider replica ting this implementation in your codebase.
*/
@Deprecated // FIXME: 0.43 - remove deprecated class
public final class IgnoreConsumedEvent<T> implements ConsumableEvent<T> {
private final T event;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright © 2018 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.concurrent.api.Publisher;

/**
* An interface which allows controlling reserving connections which maybe used concurrently.
*
* @deprecated This interface is not used by ServiceTalk internal code anymore and will be removed in the future
* releases. If you depend on it, consider replicating this implementation in your codebase or reach out to us
* explaining the use-case.
*/
@Deprecated // FIXME: 0.43 - remove deprecated interface
public interface RequestConcurrencyController {

/**
* Result of the {@link #tryRequest()} call.
*/
enum Result {
/**
* Selecting the resource succeeded.
*/
Accepted,
/**
* Selecting the resource was denied, but may succeed at later time.
*/
RejectedTemporary,
/**
* Selecting the resource was denied, and will not succeed at later time.
*/
RejectedPermanently
}

/**
* Attempts to reserve a connection for a single request, needs to be followed by {@link #requestFinished()}.
* @return {@link Result#Accepted} if this connection is available and reserved for performing a single request.
*/
Result tryRequest();

/**
* Must be called after {@link #tryRequest()} to signify the request has completed. This method should be called
* no more than once for each call to {@link #tryRequest()}.
* <p>
* Generally called from a {@link Publisher#beforeFinally(Runnable)} after a {@link #tryRequest()}.
*/
void requestFinished();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedTemporary;

@Deprecated // FIXME: 0.43 - remove deprecated class
final class RequestConcurrencyControllerMulti extends AbstractRequestConcurrencyController {
private final int maxRequests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedTemporary;

@Deprecated // FIXME: 0.43 - remove deprecated class
final class RequestConcurrencyControllerOnlySingle extends AbstractRequestConcurrencyController {
RequestConcurrencyControllerOnlySingle(final Publisher<? extends ConsumableEvent<Integer>> maxConcurrency,
final Completable onClosing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.ConsumableEvent;
import io.servicetalk.client.api.RequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

/**
* Factory for common {@link RequestConcurrencyController}s.
*
* @deprecated This class is not used by ServiceTalk internal code anymore and will be removed in the future releases.
* If you depend on it, consider replicating this implementation in your codebase.
*/
public final class RequestConcurrencyControllers {
@Deprecated
public final class RequestConcurrencyControllers { // FIXME: 0.43 - remove deprecated class
private RequestConcurrencyControllers() {
// no instances
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright © 2018 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.concurrent.api.Completable;

/**
* A {@link RequestConcurrencyController} that also allows to {@link #tryReserve()} a connection for exclusive use.
*
* @deprecated This interface is not used by ServiceTalk internal code anymore and will be removed in the future
* releases. If you depend on it, consider replicating this implementation in your codebase or reach out to us
* explaining the use-case.
*/
@Deprecated // FIXME: 0.43 - remove deprecated interface
public interface ReservableRequestConcurrencyController extends RequestConcurrencyController {

/**
* Attempts to reserve a connection for exclusive use until {@link #releaseAsync()} is called.
* @return {@code true} if this connection is available and reserved for performing a single request.
*/
boolean tryReserve();

/**
* Must be called (and subscribed to) to signify the reservation has completed after {@link #tryReserve()}.
* @return a {@link Completable} for the release.
*/
Completable releaseAsync();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedTemporary;

@Deprecated // FIXME: 0.43 - remove deprecated class
final class ReservableRequestConcurrencyControllerMulti extends AbstractReservableRequestConcurrencyController {
private final int maxRequests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedTemporary;

@Deprecated // FIXME: 0.43 - remove deprecated class
final class ReservableRequestConcurrencyControllerOnlySingle extends AbstractReservableRequestConcurrencyController {
ReservableRequestConcurrencyControllerOnlySingle(final Publisher<? extends ConsumableEvent<Integer>> maxConcurrency,
final Completable onClosing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.ConsumableEvent;
import io.servicetalk.client.api.RequestConcurrencyController;
import io.servicetalk.client.api.ReservableRequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

/**
* Factory for common {@link ReservableRequestConcurrencyController}s.
*
* @deprecated This class is not used by ServiceTalk internal code anymore and will be removed in the future releases.
* If you depend on it, consider replicating this implementation in your codebase.
*/
@Deprecated
public final class ReservableRequestConcurrencyControllers {
private ReservableRequestConcurrencyControllers() {
private ReservableRequestConcurrencyControllers() { // FIXME: 0.43 - remove deprecated class
// no instances
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.RequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;
import io.servicetalk.concurrent.api.TestPublisher;

import org.junit.jupiter.api.Test;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.concurrent.api.Completable.completed;
import static io.servicetalk.concurrent.api.Completable.never;
import static io.servicetalk.concurrent.api.Publisher.from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.RequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;
import io.servicetalk.concurrent.api.TestPublisher;

import org.junit.jupiter.api.Test;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedPermanently;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.RejectedTemporary;
import static io.servicetalk.concurrent.api.Completable.completed;
import static io.servicetalk.concurrent.api.Completable.never;
import static io.servicetalk.concurrent.api.Publisher.from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.RequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.RequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.ReservableRequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

import org.junit.jupiter.api.Test;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.concurrent.api.Completable.never;
import static io.servicetalk.concurrent.api.Publisher.from;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
*/
package io.servicetalk.client.api.internal;

import io.servicetalk.client.api.ReservableRequestConcurrencyController;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;

import org.junit.jupiter.api.Test;

import static io.servicetalk.client.api.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.RequestConcurrencyController.Result.Accepted;
import static io.servicetalk.client.api.internal.ReservableRequestConcurrencyControllers.newSingleController;
import static io.servicetalk.concurrent.api.Completable.never;
import static io.servicetalk.concurrent.api.Publisher.from;
Expand Down
1 change: 0 additions & 1 deletion servicetalk-dns-discovery-netty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencies {
api project(":servicetalk-client-api")

implementation project(":servicetalk-annotations")
implementation project(":servicetalk-client-api-internal")
implementation project(":servicetalk-concurrent-internal")
implementation project(":servicetalk-concurrent-api-internal")
implementation project(":servicetalk-transport-netty")
Expand Down
1 change: 0 additions & 1 deletion servicetalk-http-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dependencies {
api project(":servicetalk-encoding-api")

implementation project(":servicetalk-annotations")
implementation project(":servicetalk-client-api-internal")
implementation project(":servicetalk-concurrent-internal")
implementation project(":servicetalk-concurrent-api-internal")
implementation project(":servicetalk-encoding-api-internal")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2018-2019, 2021 Apple Inc. and the ServiceTalk project authors
* Copyright © 2018-2019, 2021-2022 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,6 @@
package io.servicetalk.http.netty;

import io.servicetalk.client.api.ConsumableEvent;
import io.servicetalk.client.api.internal.IgnoreConsumedEvent;
import io.servicetalk.concurrent.api.Completable;
import io.servicetalk.concurrent.api.Publisher;
import io.servicetalk.concurrent.api.Single;
Expand All @@ -36,6 +35,7 @@
import io.servicetalk.http.api.StreamingHttpResponse;
import io.servicetalk.http.api.StreamingHttpResponseFactory;
import io.servicetalk.http.netty.LoadBalancedStreamingHttpClient.OnStreamClosedRunnable;
import io.servicetalk.http.netty.ReservableRequestConcurrencyControllers.IgnoreConsumedEvent;
import io.servicetalk.transport.api.IoThreadFactory;
import io.servicetalk.transport.netty.internal.FlushStrategy;
import io.servicetalk.transport.netty.internal.NettyConnectionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
import java.util.function.Function;
import javax.annotation.Nullable;

import static io.servicetalk.client.api.internal.ReservableRequestConcurrencyControllers.newController;
import static io.servicetalk.concurrent.api.Single.failed;
import static io.servicetalk.http.netty.AlpnIds.HTTP_1_1;
import static io.servicetalk.http.netty.AlpnIds.HTTP_2;
import static io.servicetalk.http.netty.ReservableRequestConcurrencyControllers.newController;
import static io.servicetalk.http.netty.StreamingConnectionFactory.withSslConfigPeerHost;

final class AlpnLBHttpConnectionFactory<ResolvedAddress> extends AbstractLBHttpConnectionFactory<ResolvedAddress> {
Expand Down
Loading

0 comments on commit 5cfe9c4

Please sign in to comment.