Google Cloud Pub/Sub C++ Client  1.33.0
A C++ Client Library for Google Cloud Pub/Sub
schema_logging.h
Go to the documentation of this file.
1 // Copyright 2021 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_SCHEMA_LOGGING_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_SCHEMA_LOGGING_H
17 
18 #include "google/cloud/pubsub/internal/schema_stub.h"
19 #include "google/cloud/pubsub/version.h"
20 #include "google/cloud/tracing_options.h"
21 #include <memory>
22 
23 namespace google {
24 namespace cloud {
25 namespace pubsub_internal {
27 
28 /**
29  * A Decorator for `SchemaStub` that logs each request and response.
30  */
31 class SchemaLogging : public SchemaStub {
32  public:
33  SchemaLogging(std::shared_ptr<SchemaStub> child,
34  TracingOptions tracing_options)
35  : child_(std::move(child)),
36  tracing_options_(std::move(tracing_options)) {}
37 
38  StatusOr<google::pubsub::v1::Schema> CreateSchema(
39  grpc::ClientContext& context,
40  google::pubsub::v1::CreateSchemaRequest const& request) override;
41  StatusOr<google::pubsub::v1::Schema> GetSchema(
42  grpc::ClientContext& context,
43  google::pubsub::v1::GetSchemaRequest const& request) override;
44  StatusOr<google::pubsub::v1::ListSchemasResponse> ListSchemas(
45  grpc::ClientContext& context,
46  google::pubsub::v1::ListSchemasRequest const& request) override;
47  Status DeleteSchema(
48  grpc::ClientContext& context,
49  google::pubsub::v1::DeleteSchemaRequest const& request) override;
50  StatusOr<google::pubsub::v1::ValidateSchemaResponse> ValidateSchema(
51  grpc::ClientContext& context,
52  google::pubsub::v1::ValidateSchemaRequest const& request) override;
53  StatusOr<google::pubsub::v1::ValidateMessageResponse> ValidateMessage(
54  grpc::ClientContext& context,
55  google::pubsub::v1::ValidateMessageRequest const& request) override;
56 
57  private:
58  std::shared_ptr<SchemaStub> child_;
59  TracingOptions tracing_options_;
60 };
61 
63 } // namespace pubsub_internal
64 } // namespace cloud
65 } // namespace google
66 
67 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_SCHEMA_LOGGING_H