Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions google/cloud/storage/async/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ future<StatusOr<google::storage::v2::Object>> AsyncClient::InsertObject(
future<StatusOr<ObjectDescriptor>> AsyncClient::Open(
BucketName const& bucket_name, std::string object_name, Options opts) {
auto spec = google::storage::v2::BidiReadObjectSpec{};
std::cerr << "Hey this is a test statement of new branch.\n";
spec.set_bucket(bucket_name.FullName());
spec.set_object(std::move(object_name));
return Open(std::move(spec), std::move(opts));
}

future<StatusOr<ObjectDescriptor>> AsyncClient::Open(
google::storage::v2::BidiReadObjectSpec spec, Options opts) {
return connection_
std::cerr << "Hey this is a test statement of new branch.\n";
return connection_
->Open({std::move(spec),
internal::MergeOptions(std::move(opts), connection_->options())})
.then([](auto f) -> StatusOr<ObjectDescriptor> {
Expand Down Expand Up @@ -116,7 +118,8 @@ future<StatusOr<std::pair<AsyncWriter, AsyncToken>>>
AsyncClient::StartAppendableObjectUpload(BucketName const& bucket_name,
std::string object_name,
Options opts) {
auto request = google::storage::v2::BidiWriteObjectRequest{};
std::cerr << "Hey this is a test statement of new branch.\n";
auto request = google::storage::v2::BidiWriteObjectRequest{};
auto& resource = *request.mutable_write_object_spec()->mutable_resource();

resource.set_bucket(BucketName(bucket_name).FullName());
Expand All @@ -129,7 +132,11 @@ AsyncClient::StartAppendableObjectUpload(BucketName const& bucket_name,
future<StatusOr<std::pair<AsyncWriter, AsyncToken>>>
AsyncClient::StartAppendableObjectUpload(
google::storage::v2::BidiWriteObjectRequest request, Options opts) {
return connection_
std::cerr << "Hey this is a test statement of new branch.\n";
return make_ready_future(
StatusOr<std::pair<AsyncWriter, AsyncToken>>(Status(
StatusCode::kInternal, "msg")));
return connection_
->StartAppendableObjectUpload(
{std::move(request),
internal::MergeOptions(std::move(opts), connection_->options())})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class AsyncWriterConnectionResumedState
resend_buffer_.Append(WritePayloadImpl::GetImpl(p));
finalize_ = true;
HandleNewData(std::move(lk));
// Return the unique future associated with this finalization.
// Returns the unique future associated with this finalization.
return std::move(finalized_future_);
}

Expand Down Expand Up @@ -184,6 +184,7 @@ class AsyncWriterConnectionResumedState
}

void WriteLoop(std::unique_lock<std::mutex> lk) {
std::cerr << "Hey this is a test statement of new branch.\n";
// Determine if there's data left to write *before* potentially finalizing.
writing_ = write_offset_ < resend_buffer_.size();

Expand Down Expand Up @@ -256,8 +257,8 @@ class AsyncWriterConnectionResumedState
auto impl = Impl(lk);
lk.unlock();
impl->Query().then([this, result, w = WeakFromThis()](auto f) {
SetFlushed(std::unique_lock<std::mutex>(mu_), std::move(result));
if (auto self = w.lock()) return self->OnQuery(f.get());
SetFlushed(std::unique_lock<std::mutex>(mu_), std::move(result));
});
}

Expand Down Expand Up @@ -463,8 +464,8 @@ class AsyncWriterConnectionResumedState
flushed.set_value(result);
// Restart the write loop ONLY if we are not already finalizing.
// If finalizing_ is true, the completion will be handled by OnFinalize.
std::unique_lock<std::mutex> loop_lk(mu_);
if (!finalizing_) WriteLoop(std::move(loop_lk));
// std::unique_lock<std::mutex> loop_lk(mu_);
// if (!finalizing_) WriteLoop(std::move(loop_lk));
}

void SetError(std::unique_lock<std::mutex> lk, Status const& status) {
Expand Down