Skip to content

Commit 1bd6270

Browse files
bajajneha27ddelgrosso1
authored andcommitted
Impl(ACv2): set timeout for appendable write (#100)
1 parent ca57e7f commit 1bd6270

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

google/cloud/storage/internal/async/connection_impl.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ AsyncConnectionImpl::StartAppendableObjectUpload(AppendableUploadParams p) {
301301
auto retry = std::shared_ptr<storage::RetryPolicy>(retry_policy(*current));
302302
auto backoff =
303303
std::shared_ptr<storage::BackoffPolicy>(backoff_policy(*current));
304+
using StreamingRpcTimeout =
305+
google::cloud::internal::AsyncStreamingReadWriteRpcTimeout<
306+
google::storage::v2::BidiWriteObjectRequest,
307+
google::storage::v2::BidiWriteObjectResponse>;
304308
struct RequestPlaceholder {};
305309

306310
using WriteResultFactory =
@@ -312,13 +316,19 @@ AsyncConnectionImpl::StartAppendableObjectUpload(AppendableUploadParams p) {
312316
backoff = std::move(backoff), current, function_name = __func__](
313317
google::storage::v2::BidiWriteObjectRequest req) {
314318
auto call = [stub, request = std::move(req)](
315-
CompletionQueue& cq_ref,
319+
CompletionQueue& cq,
316320
std::shared_ptr<grpc::ClientContext> context,
317321
google::cloud::internal::ImmutableOptions options,
318322
RequestPlaceholder const&) mutable
319323
-> future<StatusOr<WriteObject::WriteResult>> {
320-
auto rpc = stub->AsyncBidiWriteObject(cq_ref, std::move(context),
324+
auto timeout = ScaleStallTimeout(
325+
options->get<storage::TransferStallTimeoutOption>(),
326+
options->get<storage::TransferStallMinimumRateOption>(),
327+
google::storage::v2::ServiceConstants::MAX_WRITE_CHUNK_BYTES);
328+
auto rpc = stub->AsyncBidiWriteObject(cq, std::move(context),
321329
std::move(options));
330+
rpc = std::make_unique<StreamingRpcTimeout>(cq, timeout, timeout,
331+
timeout, std::move(rpc));
322332
request.set_state_lookup(true);
323333
auto open = std::make_shared<WriteObject>(std::move(rpc), request);
324334
return open->Call().then([open, &request](auto f) {

0 commit comments

Comments
 (0)