FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: update grpc based ReadObject rpcs to remove race condition between cancellation and message handling by BenWhitehead · Pull Request #2708 · googleapis/java-storage · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (9) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or 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
Expand Up @@ -20,8 +20,10 @@

import com.google.api.core.ApiFutures;
import com.google.api.core.SettableApiFuture;
import com.google.api.gax.retrying.ResultRetryAlgorithm;
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.cloud.storage.BufferedReadableByteChannelSession.BufferedReadableByteChannel;
import com.google.cloud.storage.Retrying.RetryingDependencies;
import com.google.cloud.storage.UnbufferedReadableByteChannelSession.UnbufferedReadableByteChannel;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.storage.v2.Object;
Expand All @@ -43,27 +45,32 @@ public static GapicDownloadSessionBuilder create() {
return INSTANCE;
}

/**
* Any retry capability must be defined within the provided ServerStreamingCallable. The
* ultimately produced channel will not do any retries of its own.
*/
public ReadableByteChannelSessionBuilder byteChannel(
ServerStreamingCallable<ReadObjectRequest, ReadObjectResponse> read,
RetryingDependencies retryingDependencies,
ResultRetryAlgorithm<?> resultRetryAlgorithm,
ResponseContentLifecycleManager responseContentLifecycleManager) {
return new ReadableByteChannelSessionBuilder(read, responseContentLifecycleManager);
return new ReadableByteChannelSessionBuilder(
read, retryingDependencies, resultRetryAlgorithm, responseContentLifecycleManager);
}

public static final class ReadableByteChannelSessionBuilder {

private final ServerStreamingCallable<ReadObjectRequest, ReadObjectResponse> read;
private final RetryingDependencies retryingDependencies;
private final ResultRetryAlgorithm<?> resultRetryAlgorithm;
private final ResponseContentLifecycleManager responseContentLifecycleManager;
private boolean autoGzipDecompression;
private Hasher hasher;

private ReadableByteChannelSessionBuilder(
ServerStreamingCallable<ReadObjectRequest, ReadObjectResponse> read,
RetryingDependencies retryingDependencies,
ResultRetryAlgorithm<?> resultRetryAlgorithm,
ResponseContentLifecycleManager responseContentLifecycleManager) {
this.read = read;
this.retryingDependencies = retryingDependencies;
this.resultRetryAlgorithm = resultRetryAlgorithm;
this.responseContentLifecycleManager = responseContentLifecycleManager;
this.hasher = Hasher.noop();
this.autoGzipDecompression = false;
Expand Down Expand Up @@ -105,12 +112,24 @@ public UnbufferedReadableByteChannelSessionBuilder unbuffered() {
if (autoGzipDecompression) {
return new GzipReadableByteChannel(
new GapicUnbufferedReadableByteChannel(
resultFuture, read, object, hasher, responseContentLifecycleManager),
resultFuture,
read,
object,
hasher,
retryingDependencies,
resultRetryAlgorithm,
responseContentLifecycleManager),
ApiFutures.transform(
resultFuture, Object::getContentEncoding, MoreExecutors.directExecutor()));
} else {
return new GapicUnbufferedReadableByteChannel(
resultFuture, read, object, hasher, responseContentLifecycleManager);
resultFuture,
read,
object,
hasher,
retryingDependencies,
resultRetryAlgorithm,
responseContentLifecycleManager);
}
};
}
Expand Down
Loading

Back | FazBrowse Home | New Git URL