Skip to content

Commit b2d57a2

Browse files
authored
feat(logging): generate AsyncWriteLogEntries() (#10194)
1 parent 47b7029 commit b2d57a2

16 files changed

Lines changed: 246 additions & 0 deletions

generator/generator_config.textproto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ service {
941941
service_proto_path: "google/logging/v2/logging.proto"
942942
product_path: "google/cloud/logging"
943943
initial_copyright_year: "2021"
944+
gen_async_rpcs: ["WriteLogEntries"]
944945
retryable_status_codes: ["kInternal", "kUnavailable"]
945946
}
946947

google/cloud/logging/internal/logging_service_v2_auth_decorator.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ LoggingServiceV2Auth::AsyncTailLogEntries(
9393
std::move(context), auth_, StreamAuth::StreamFactory(std::move(call)));
9494
}
9595

96+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
97+
LoggingServiceV2Auth::AsyncWriteLogEntries(
98+
google::cloud::CompletionQueue& cq,
99+
std::unique_ptr<grpc::ClientContext> context,
100+
google::logging::v2::WriteLogEntriesRequest const& request) {
101+
using ReturnType = StatusOr<google::logging::v2::WriteLogEntriesResponse>;
102+
auto& child = child_;
103+
return auth_->AsyncConfigureContext(std::move(context))
104+
.then([cq, child,
105+
request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
106+
f) mutable {
107+
auto context = f.get();
108+
if (!context) {
109+
return make_ready_future(ReturnType(std::move(context).status()));
110+
}
111+
return child->AsyncWriteLogEntries(cq, *std::move(context), request);
112+
});
113+
}
114+
96115
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
97116
} // namespace logging_internal
98117
} // namespace cloud

google/cloud/logging/internal/logging_service_v2_auth_decorator.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class LoggingServiceV2Auth : public LoggingServiceV2Stub {
6666
AsyncTailLogEntries(google::cloud::CompletionQueue const& cq,
6767
std::unique_ptr<grpc::ClientContext> context) override;
6868

69+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
70+
AsyncWriteLogEntries(
71+
google::cloud::CompletionQueue& cq,
72+
std::unique_ptr<grpc::ClientContext> context,
73+
google::logging::v2::WriteLogEntriesRequest const& request) override;
74+
6975
private:
7076
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth_;
7177
std::shared_ptr<LoggingServiceV2Stub> child_;

google/cloud/logging/internal/logging_service_v2_connection_impl.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "google/cloud/background_threads.h"
2222
#include "google/cloud/common_options.h"
2323
#include "google/cloud/grpc_options.h"
24+
#include "google/cloud/internal/async_retry_loop.h"
2425
#include "google/cloud/internal/pagination_range.h"
2526
#include "google/cloud/internal/retry_loop.h"
2627
#include <memory>
@@ -159,6 +160,20 @@ StreamRange<std::string> LoggingServiceV2ConnectionImpl::ListLogs(
159160
});
160161
}
161162

163+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
164+
LoggingServiceV2ConnectionImpl::AsyncWriteLogEntries(
165+
google::logging::v2::WriteLogEntriesRequest const& request) {
166+
auto& stub = stub_;
167+
return google::cloud::internal::AsyncRetryLoop(
168+
retry_policy(), backoff_policy(),
169+
idempotency_policy()->WriteLogEntries(request), background_->cq(),
170+
[stub](CompletionQueue& cq, std::unique_ptr<grpc::ClientContext> context,
171+
google::logging::v2::WriteLogEntriesRequest const& request) {
172+
return stub->AsyncWriteLogEntries(cq, std::move(context), request);
173+
},
174+
request, __func__);
175+
}
176+
162177
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
163178
} // namespace logging_internal
164179
} // namespace cloud

google/cloud/logging/internal/logging_service_v2_connection_impl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class LoggingServiceV2ConnectionImpl
7272
google::logging::v2::TailLogEntriesResponse>>
7373
AsyncTailLogEntries(ExperimentalTag) override;
7474

75+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
76+
AsyncWriteLogEntries(
77+
google::logging::v2::WriteLogEntriesRequest const& request) override;
78+
7579
private:
7680
std::unique_ptr<logging::LoggingServiceV2RetryPolicy> retry_policy() {
7781
auto const& options = internal::CurrentOptions();

google/cloud/logging/internal/logging_service_v2_logging_decorator.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ LoggingServiceV2Logging::AsyncTailLogEntries(
117117
return stream;
118118
}
119119

120+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
121+
LoggingServiceV2Logging::AsyncWriteLogEntries(
122+
google::cloud::CompletionQueue& cq,
123+
std::unique_ptr<grpc::ClientContext> context,
124+
google::logging::v2::WriteLogEntriesRequest const& request) {
125+
return google::cloud::internal::LogWrapper(
126+
[this](google::cloud::CompletionQueue& cq,
127+
std::unique_ptr<grpc::ClientContext> context,
128+
google::logging::v2::WriteLogEntriesRequest const& request) {
129+
return child_->AsyncWriteLogEntries(cq, std::move(context), request);
130+
},
131+
cq, std::move(context), request, __func__, tracing_options_);
132+
}
133+
120134
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
121135
} // namespace logging_internal
122136
} // namespace cloud

google/cloud/logging/internal/logging_service_v2_logging_decorator.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class LoggingServiceV2Logging : public LoggingServiceV2Stub {
6666
AsyncTailLogEntries(google::cloud::CompletionQueue const& cq,
6767
std::unique_ptr<grpc::ClientContext> context) override;
6868

69+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
70+
AsyncWriteLogEntries(
71+
google::cloud::CompletionQueue& cq,
72+
std::unique_ptr<grpc::ClientContext> context,
73+
google::logging::v2::WriteLogEntriesRequest const& request) override;
74+
6975
private:
7076
std::shared_ptr<LoggingServiceV2Stub> child_;
7177
TracingOptions tracing_options_;

google/cloud/logging/internal/logging_service_v2_metadata_decorator.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ LoggingServiceV2Metadata::AsyncTailLogEntries(
8484
return child_->AsyncTailLogEntries(cq, std::move(context));
8585
}
8686

87+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
88+
LoggingServiceV2Metadata::AsyncWriteLogEntries(
89+
google::cloud::CompletionQueue& cq,
90+
std::unique_ptr<grpc::ClientContext> context,
91+
google::logging::v2::WriteLogEntriesRequest const& request) {
92+
SetMetadata(*context);
93+
return child_->AsyncWriteLogEntries(cq, std::move(context), request);
94+
}
95+
8796
void LoggingServiceV2Metadata::SetMetadata(grpc::ClientContext& context,
8897
std::string const& request_params) {
8998
context.AddMetadata("x-goog-request-params", request_params);

google/cloud/logging/internal/logging_service_v2_metadata_decorator.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ class LoggingServiceV2Metadata : public LoggingServiceV2Stub {
6363
AsyncTailLogEntries(google::cloud::CompletionQueue const& cq,
6464
std::unique_ptr<grpc::ClientContext> context) override;
6565

66+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
67+
AsyncWriteLogEntries(
68+
google::cloud::CompletionQueue& cq,
69+
std::unique_ptr<grpc::ClientContext> context,
70+
google::logging::v2::WriteLogEntriesRequest const& request) override;
71+
6672
private:
6773
void SetMetadata(grpc::ClientContext& context,
6874
std::string const& request_params);

google/cloud/logging/internal/logging_service_v2_stub.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ DefaultLoggingServiceV2Stub::AsyncTailLogEntries(
107107
});
108108
}
109109

110+
future<StatusOr<google::logging::v2::WriteLogEntriesResponse>>
111+
DefaultLoggingServiceV2Stub::AsyncWriteLogEntries(
112+
google::cloud::CompletionQueue& cq,
113+
std::unique_ptr<grpc::ClientContext> context,
114+
google::logging::v2::WriteLogEntriesRequest const& request) {
115+
return cq.MakeUnaryRpc(
116+
[this](grpc::ClientContext* context,
117+
google::logging::v2::WriteLogEntriesRequest const& request,
118+
grpc::CompletionQueue* cq) {
119+
return grpc_stub_->AsyncWriteLogEntries(context, request, cq);
120+
},
121+
request, std::move(context));
122+
}
123+
110124
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
111125
} // namespace logging_internal
112126
} // namespace cloud

0 commit comments

Comments
 (0)