Skip to content

Commit

Permalink
Cleanup HttpPredicateRouterBuilder (#2234)
Browse files Browse the repository at this point in the history
Motivation:
Some of the types used by `HttpPredicateRouterBuilder` have changed
resulting in dead code.
Modifications:
Reduce complexity by removing code paths that are now impossible.
Result:
Cleaner, more obvious implementation.
  • Loading branch information
bondolo authored Jun 3, 2022
1 parent ff6436b commit 45019c5
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.servicetalk.http.api.HttpApiConversions.ServiceAdapterHolder;
import io.servicetalk.http.api.HttpCookiePair;
import io.servicetalk.http.api.HttpExecutionStrategy;
import io.servicetalk.http.api.HttpExecutionStrategyInfluencer;
import io.servicetalk.http.api.HttpRequestMethod;
import io.servicetalk.http.api.HttpService;
import io.servicetalk.http.api.StreamingHttpRequest;
Expand All @@ -29,7 +30,6 @@
import io.servicetalk.http.router.predicate.dsl.RouteStarter;
import io.servicetalk.http.router.predicate.dsl.StringMultiValueMatcher;
import io.servicetalk.transport.api.ConnectionContext;
import io.servicetalk.transport.api.ExecutionStrategyInfluencer;

import java.util.ArrayList;
import java.util.Iterator;
Expand All @@ -42,7 +42,6 @@
import javax.annotation.Nullable;

import static io.servicetalk.http.api.HttpApiConversions.toStreamingHttpService;
import static io.servicetalk.http.api.HttpExecutionStrategies.defaultStrategy;
import static io.servicetalk.http.router.predicate.Predicates.method;
import static io.servicetalk.http.router.predicate.Predicates.methodIsOneOf;
import static io.servicetalk.http.router.predicate.Predicates.pathEquals;
Expand Down Expand Up @@ -276,15 +275,11 @@ public RouteStarter thenRouteTo(final BlockingStreamingHttpService service) {
return thenRouteTo0(adapterHolder.adaptor(), adapterHolder.serviceInvocationStrategy());
}

private HttpExecutionStrategy serviceOffloads(final Object service) {
return null != strategy ? strategy :
service instanceof ExecutionStrategyInfluencer ?
HttpExecutionStrategy.from(((ExecutionStrategyInfluencer) service).requiredOffloads()) :
defaultStrategy();
private HttpExecutionStrategy serviceOffloads(final HttpExecutionStrategyInfluencer service) {
return null != strategy ? strategy : service.requiredOffloads();
}

private RouteStarter thenRouteTo0(final StreamingHttpService route,
@Nullable final HttpExecutionStrategy routeStrategy) {
private RouteStarter thenRouteTo0(final StreamingHttpService route, final HttpExecutionStrategy routeStrategy) {
assert predicate != null;
routes.add(new Route(predicate, route, null == strategy ? null : routeStrategy));
// Reset shared state since we have finished current route construction
Expand Down

0 comments on commit 45019c5

Please sign in to comment.