-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
… retryer (#432) Replace QueuedChannel with a backoff based retryer
- Loading branch information
1 parent
7b456ec
commit 7d32799
Showing
89 changed files
with
374 additions
and
943 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type: improvement | ||
improvement: | ||
description: Replace QueuedChannel with a backoff based retryer | ||
links: | ||
- https://github.com/palantir/dialogue/pull/432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
dialogue-core/src/main/java/com/palantir/dialogue/core/LimitedChannelListener.java
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
dialogue-core/src/main/java/com/palantir/dialogue/core/LimitedChannelToChannelAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* (c) Copyright 2020 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.dialogue.core; | ||
|
||
import com.google.common.util.concurrent.Futures; | ||
import com.google.common.util.concurrent.ListenableFuture; | ||
import com.palantir.dialogue.Channel; | ||
import com.palantir.dialogue.Endpoint; | ||
import com.palantir.dialogue.Request; | ||
import com.palantir.dialogue.Response; | ||
import com.palantir.logsafe.Preconditions; | ||
import com.palantir.logsafe.exceptions.SafeRuntimeException; | ||
import java.util.function.Supplier; | ||
|
||
/** Adapter from {@link LimitedChannel} to {@link Channel} which produces a failed future when results are limited. */ | ||
final class LimitedChannelToChannelAdapter implements Channel { | ||
|
||
// Avoid method reference allocations | ||
@SuppressWarnings("UnnecessaryLambda") | ||
private static final Supplier<ListenableFuture<Response>> limitedResultSupplier = | ||
() -> Futures.immediateFailedFuture(new SafeRuntimeException("Failed to make a request")); | ||
|
||
private final LimitedChannel delegate; | ||
|
||
LimitedChannelToChannelAdapter(LimitedChannel delegate) { | ||
this.delegate = Preconditions.checkNotNull(delegate, "LimitedChannel"); | ||
} | ||
|
||
@Override | ||
public ListenableFuture<Response> execute(Endpoint endpoint, Request request) { | ||
return delegate.maybeExecute(endpoint, request).orElseGet(limitedResultSupplier); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "LimitedChannelToChannelAdapter{delegate=" + delegate + '}'; | ||
} | ||
} |
Oops, something went wrong.