Skip to content
Open
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
1 change: 0 additions & 1 deletion google/cloud/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ cc_library(
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/time",
"@abseil-cpp//absl/types:optional",
"@abseil-cpp//absl/types:span",
"@abseil-cpp//absl/types:variant",
"@opentelemetry-cpp//api",
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/async_streaming_read_write_rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "google/cloud/rpc_metadata.h"
#include "google/cloud/status.h"
#include "google/cloud/version.h"
#include "absl/types/optional.h"
#include <grpcpp/support/async_stream.h>
#include <optional>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -77,7 +77,7 @@ class AsyncStreamingReadWriteRpc {
* other `Write()` calls) complete and then call `Finish()` to find the status
* of the streaming RPC.
*/
virtual future<absl::optional<Response>> Read() = 0;
virtual future<std::optional<Response>> Read() = 0;

/**
* Write one request to the streaming RPC.
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/credentials.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ std::shared_ptr<Credentials> MakeImpersonateServiceAccountCredentials(
std::shared_ptr<Credentials> MakeServiceAccountCredentials(
std::string json_object, Options opts) {
return std::make_shared<internal::ServiceAccountConfig>(
std::move(json_object), absl::nullopt, std::move(opts));
std::move(json_object), std::nullopt, std::move(opts));
}

std::shared_ptr<Credentials> MakeServiceAccountCredentialsFromFile(
std::string const& file_path, Options opts) {
return std::make_shared<internal::ServiceAccountConfig>(
absl::nullopt, file_path, std::move(opts));
std::nullopt, file_path, std::move(opts));
}

std::shared_ptr<Credentials> MakeExternalAccountCredentials(
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/grpc_error_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

#include "google/cloud/grpc_error_delegate.h"
#include "google/cloud/internal/status_payload_keys.h"
#include "absl/types/optional.h"
#include "google/protobuf/any.pb.h"
#include "google/rpc/error_details.pb.h"
#include <google/protobuf/text_format.h>
#include <optional>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -67,7 +67,7 @@ google::cloud::StatusCode MapStatusCode(grpc::StatusCode const& code) {
}

// Unpacks the ErrorInfo from the Status proto, if one exists.
absl::optional<google::rpc::ErrorInfo> GetErrorInfoProto(
std::optional<google::rpc::ErrorInfo> GetErrorInfoProto(
google::rpc::Status const& proto) {
// While in theory there _could_ be multiple ErrorInfo protos in this
// repeated field, we're told that there will be at most one, and our
Expand All @@ -76,7 +76,7 @@ absl::optional<google::rpc::ErrorInfo> GetErrorInfoProto(
for (google::protobuf::Any const& any : proto.details()) {
if (any.UnpackTo(&error_info)) return error_info;
}
return absl::nullopt;
return std::nullopt;
}

ErrorInfo GetErrorInfo(google::rpc::Status const& status) {
Expand All @@ -88,7 +88,7 @@ ErrorInfo GetErrorInfo(google::rpc::Status const& status) {
}

// Unpacks the RetryInfo from the Status proto, if one exists.
absl::optional<internal::RetryInfo> GetRetryInfo(
std::optional<internal::RetryInfo> GetRetryInfo(
google::rpc::Status const& proto) {
// While in theory there _could_ be multiple RetryInfo protos in this
// repeated field, we're told that there will be at most one, and our
Expand All @@ -101,7 +101,7 @@ absl::optional<internal::RetryInfo> GetRetryInfo(
return internal::RetryInfo(d);
}
}
return absl::nullopt;
return std::nullopt;
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/grpc_error_delegate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ TEST(MakeStatusFromRpcError, AllCodesWithPayload) {
EXPECT_EQ(expected, actual);
EXPECT_EQ(message, actual.message());
EXPECT_EQ(ErrorInfo{}, actual.error_info());
EXPECT_EQ(absl::nullopt, internal::GetRetryInfo(actual));
EXPECT_EQ(std::nullopt, internal::GetRetryInfo(actual));

// Make sure the actual payload is what we expect.
auto actual_payload = google::cloud::internal::GetPayload(
Expand Down
12 changes: 6 additions & 6 deletions google/cloud/grpc_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,30 @@ grpc::ChannelArguments MakeChannelArguments(Options const& opts) {
return channel_arguments;
}

absl::optional<int> GetIntChannelArgument(grpc::ChannelArguments const& args,
std::optional<int> GetIntChannelArgument(grpc::ChannelArguments const& args,
std::string const& key) {
auto c_args = args.c_channel_args();
// Just do a linear search for the key; the data structure is not organized
// in any other useful way.
for (auto const* a = c_args.args; a != c_args.args + c_args.num_args; ++a) {
if (key != a->key) continue;
if (a->type != GRPC_ARG_INTEGER) return absl::nullopt;
if (a->type != GRPC_ARG_INTEGER) return std::nullopt;
return a->value.integer;
}
return absl::nullopt;
return std::nullopt;
}

absl::optional<std::string> GetStringChannelArgument(
std::optional<std::string> GetStringChannelArgument(
grpc::ChannelArguments const& args, std::string const& key) {
auto c_args = args.c_channel_args();
// Just do a linear search for the key; the data structure is not organized
// in any other useful way.
for (auto const* a = c_args.args; a != c_args.args + c_args.num_args; ++a) {
if (key != a->key) continue;
if (a->type != GRPC_ARG_STRING) return absl::nullopt;
if (a->type != GRPC_ARG_STRING) return std::nullopt;
return a->value.string;
}
return absl::nullopt;
return std::nullopt;
}

BackgroundThreadsFactory MakeBackgroundThreadsFactory(Options const& opts) {
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/grpc_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ std::string MakeGrpcHttpProxy(ProxyConfig const& config);
grpc::ChannelArguments MakeChannelArguments(Options const& opts);

/// Helper function to extract the first instance of an integer channel argument
absl::optional<int> GetIntChannelArgument(grpc::ChannelArguments const& args,
std::optional<int> GetIntChannelArgument(grpc::ChannelArguments const& args,
std::string const& key);

/// Helper function to extract the first instance of a string channel argument
absl::optional<std::string> GetStringChannelArgument(
std::optional<std::string> GetStringChannelArgument(
grpc::ChannelArguments const& args, std::string const& key);

/**
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/iam_updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_UPDATER_H

#include "google/cloud/version.h"
#include "absl/types/optional.h"
#include "google/iam/v1/policy.pb.h"
#include <functional>
#include <optional>

namespace google {
namespace cloud {
Expand All @@ -38,7 +38,7 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
* has been an intermediate update), this update is dropped and a new cycle is
* initiated. In case (2) the existing policy is overwritten blindly.
*/
using IamUpdater = std::function<absl::optional<google::iam::v1::Policy>(
using IamUpdater = std::function<std::optional<google::iam::v1::Policy>(
google::iam::v1::Policy)>;

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/internal/async_read_write_stream_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AsyncStreamingReadWriteRpcAuth
});
}

future<absl::optional<Response>> Read() override {
future<std::optional<Response>> Read() override {
std::lock_guard<std::mutex> g{state_->mu};
return state_->stream->Read();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TEST(AsyncStreamReadWriteAuth, Start) {
return make_ready_future(true);
});
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::make_optional(FakeResponse{"k0", "v0"}));
return make_ready_future(std::make_optional(FakeResponse{"k0", "v0"}));
});
EXPECT_CALL(*mock, WritesDone).WillOnce([] {
return make_ready_future(true);
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/internal/async_read_write_stream_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include "google/cloud/options.h"
#include "google/cloud/version.h"
#include "absl/functional/function_ref.h"
#include "absl/types/optional.h"
#include <grpcpp/support/async_stream.h>
#include <memory>
#include <optional>
#include <utility>

namespace google {
Expand Down Expand Up @@ -76,7 +76,7 @@ class AsyncStreamingReadWriteRpcImpl
return op->p.get_future();
}

future<absl::optional<Response>> Read() override {
future<std::optional<Response>> Read() override {
struct OnRead : public AsyncGrpcOperation {
explicit OnRead(ImmutableOptions o) : call_context(std::move(o)) {}

Expand All @@ -91,7 +91,7 @@ class AsyncStreamingReadWriteRpcImpl
}
void Cancel() override {}

promise<absl::optional<Response>> p;
promise<std::optional<Response>> p;
Response response;
CallContext call_context;
};
Expand Down Expand Up @@ -223,8 +223,8 @@ class AsyncStreamingReadWriteRpcError

void Cancel() override {}
future<bool> Start() override { return make_ready_future(false); }
future<absl::optional<Response>> Read() override {
return make_ready_future<absl::optional<Response>>(absl::nullopt);
future<std::optional<Response>> Read() override {
return make_ready_future<std::optional<Response>>(std::nullopt);
}
future<bool> Write(Request const&, grpc::WriteOptions) override {
return make_ready_future(false);
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/internal/async_read_write_stream_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class AsyncStreamingReadWriteRpcLogging
});
}

future<absl::optional<Response>> Read() override {
future<std::optional<Response>> Read() override {
auto prefix = std::string(__func__) + "(" + request_id_ + ")";
auto const& opt = tracing_options_;
GCP_LOG(DEBUG) << prefix << " <<";
return child_->Read().then(
[prefix, opt](future<absl::optional<Response>> f) {
[prefix, opt](future<std::optional<Response>> f) {
auto r = f.get();
if (r.has_value()) {
GCP_LOG(DEBUG) << prefix << " >> " << DebugString(*r, opt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_F(StreamingReadRpcLoggingTest, Start) {
TEST_F(StreamingReadRpcLoggingTest, ReadWithValue) {
auto mock = std::make_unique<MockStream>();
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::make_optional(google::protobuf::Duration{}));
return make_ready_future(std::make_optional(google::protobuf::Duration{}));
});
TestedStream stream(std::move(mock), TracingOptions{}, "test-id");
EXPECT_TRUE(stream.Read().get().has_value());
Expand All @@ -79,7 +79,7 @@ TEST_F(StreamingReadRpcLoggingTest, ReadWithValue) {
TEST_F(StreamingReadRpcLoggingTest, ReadWithout) {
auto mock = std::make_unique<MockStream>();
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::optional<google::protobuf::Duration>{});
return make_ready_future(std::optional<google::protobuf::Duration>{});
});
TestedStream stream(std::move(mock), TracingOptions{}, "test-id");
ASSERT_FALSE(stream.Read().get().has_value());
Expand Down
12 changes: 6 additions & 6 deletions google/cloud/internal/async_read_write_stream_timeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AsyncStreamingReadWriteRpcTimeout

future<bool> Start() override { return state_->Start(); }

future<absl::optional<Response>> Read() override { return state_->Read(); }
future<std::optional<Response>> Read() override { return state_->Read(); }

future<bool> Write(Request const& request,
grpc::WriteOptions options) override {
Expand Down Expand Up @@ -117,23 +117,23 @@ class AsyncStreamingReadWriteRpcTimeout
});
}

future<absl::optional<Response>> Read() {
future<std::optional<Response>> Read() {
auto watchdog = CreateWatchdog(per_read_timeout);
return child->Read().then(
[wd = std::move(watchdog), w = WeakFromThis()](auto f) mutable {
if (auto self = w.lock())
return self->OnRead(std::move(wd), f.get());
return make_ready_future(absl::optional<Response>{});
return make_ready_future(std::optional<Response>{});
});
}

future<absl::optional<Response>> OnRead(future<bool> watchdog,
absl::optional<Response> response) {
future<std::optional<Response>> OnRead(future<bool> watchdog,
std::optional<Response> response) {
watchdog.cancel();
return watchdog.then(
[w = WeakFromThis(), r = std::move(response)](auto f) mutable {
auto expired = f.get();
if (expired) return absl::optional<Response>{};
if (expired) return std::optional<Response>{};
return std::move(r);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ TEST(AsyncStreamingReadWriteRpcTimeout, ReadSuccess) {
auto mock = std::make_unique<MockStream>();
EXPECT_CALL(*mock, Read).WillOnce([&] {
return sequencer.PushBack("Read").then(
[](auto) { return absl::make_optional(std::string("42")); });
[](auto) { return std::make_optional(std::string("42")); });
});
EXPECT_CALL(*mock, Cancel).Times(0);

Expand Down Expand Up @@ -161,7 +161,7 @@ TEST(AsyncStreamingReadWriteRpcTimeout, ReadTimeout) {
auto mock = std::make_unique<MockStream>();
EXPECT_CALL(*mock, Read).WillOnce([&] {
return sequencer.PushBack("Read").then(
[](auto) { return absl::make_optional(std::string("42")); });
[](auto) { return std::make_optional(std::string("42")); });
});
EXPECT_CALL(*mock, Cancel).Times(1);

Expand All @@ -183,7 +183,7 @@ TEST(AsyncStreamingReadWriteRpcTimeout, ReadTimeout) {
ASSERT_THAT(read.second, "Read");
timer.first.set_value(true);
read.first.set_value(true);
EXPECT_EQ(result.get(), absl::optional<std::string>{});
EXPECT_EQ(result.get(), std::optional<std::string>{});
}

TEST(AsyncStreamingReadWriteRpcTimeout, WriteSuccess) {
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/internal/async_read_write_stream_tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class AsyncStreamingReadWriteRpcTracing
});
}

future<absl::optional<Response>> Read() override {
future<std::optional<Response>> Read() override {
if (read_count_ == 0) span_->AddEvent("gl-cpp.first-read");
return impl_->Read().then([this](future<absl::optional<Response>> f) {
return impl_->Read().then([this](future<std::optional<Response>> f) {
auto r = f.get();
if (r.has_value()) {
span_->AddEvent("message", {{"message.type", "RECEIVED"},
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/internal/async_read_write_stream_tracing_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ TEST(AsyncStreamingReadWriteRpcTracing, Read) {
auto span = MakeSpan("span");
auto mock = std::make_unique<MockStream>();
EXPECT_CALL(*mock, Read)
.WillOnce([] { return make_ready_future(absl::make_optional(100)); })
.WillOnce([] { return make_ready_future(absl::make_optional(200)); })
.WillOnce([] { return make_ready_future(absl::make_optional(300)); })
.WillOnce([] { return make_ready_future(std::make_optional(100)); })
.WillOnce([] { return make_ready_future(std::make_optional(200)); })
.WillOnce([] { return make_ready_future(std::make_optional(300)); })
.WillOnce(
[] { return make_ready_future<absl::optional<int>>(absl::nullopt); });
[] { return make_ready_future<std::optional<int>>(std::nullopt); });
EXPECT_CALL(*mock, Finish)
.WillOnce(Return(make_ready_future(internal::AbortedError("fail"))));

Expand Down Expand Up @@ -207,7 +207,7 @@ TEST(AsyncStreamingReadWriteRpcTracing, SeparateCountersForReadAndWrite) {
auto mock = std::make_unique<MockStream>();
EXPECT_CALL(*mock, Write).WillOnce(Return(make_ready_future(true)));
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::make_optional(100));
return make_ready_future(std::make_optional(100));
});
EXPECT_CALL(*mock, Finish)
.WillOnce(Return(make_ready_future(internal::AbortedError("fail"))));
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/internal/async_streaming_read_rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "google/cloud/rpc_metadata.h"
#include "google/cloud/status.h"
#include "google/cloud/version.h"
#include "absl/types/optional.h"
#include <grpcpp/support/async_stream.h>
#include <optional>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -75,7 +75,7 @@ class AsyncStreamingReadRpc {
* library should then call `Finish()` to find out if the streaming RPC
* was successful or completed with an error.
*/
virtual future<absl::optional<Response>> Read() = 0;
virtual future<std::optional<Response>> Read() = 0;

/**
* Return the final status of the streaming RPC.
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/internal/async_streaming_read_rpc_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AsyncStreamingReadRpcAuth : public AsyncStreamingReadRpc<Response> {
});
}

future<absl::optional<Response>> Read() override {
future<std::optional<Response>> Read() override {
std::lock_guard<std::mutex> g{state_->mu};
return state_->stream->Read();
}
Expand Down
Loading
Loading