Google Cloud BigQuery C++ Client  2.1.0
A C++ Client Library for Google Cloud BigQuery
bigquery_write_connection.h
Go to the documentation of this file.
1 // Copyright 2022 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 // https://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 // Generated by the Codegen C++ plugin.
16 // If you make any local changes, they will be lost.
17 // source: google/cloud/bigquery/storage/v1/storage.proto
18 
19 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_BIGQUERY_WRITE_CONNECTION_H
20 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_BIGQUERY_WRITE_CONNECTION_H
21 
22 #include "google/cloud/bigquery/bigquery_write_connection_idempotency_policy.h"
23 #include "google/cloud/bigquery/internal/bigquery_write_retry_traits.h"
24 #include "google/cloud/bigquery/internal/bigquery_write_stub.h"
25 #include "google/cloud/backoff_policy.h"
26 #include "google/cloud/experimental_tag.h"
27 #include "google/cloud/internal/async_read_write_stream_impl.h"
28 #include "google/cloud/options.h"
29 #include "google/cloud/status_or.h"
30 #include "google/cloud/version.h"
31 #include <memory>
32 
33 namespace google {
34 namespace cloud {
35 namespace bigquery {
37 
38 using BigQueryWriteRetryPolicy =
39  ::google::cloud::internal::TraitBasedRetryPolicy<
40  bigquery_internal::BigQueryWriteRetryTraits>;
41 
42 using BigQueryWriteLimitedTimeRetryPolicy =
43  ::google::cloud::internal::LimitedTimeRetryPolicy<
44  bigquery_internal::BigQueryWriteRetryTraits>;
45 
46 using BigQueryWriteLimitedErrorCountRetryPolicy =
47  ::google::cloud::internal::LimitedErrorCountRetryPolicy<
48  bigquery_internal::BigQueryWriteRetryTraits>;
49 
50 /**
51  * The `BigQueryWriteConnection` object for `BigQueryWriteClient`.
52  *
53  * This interface defines virtual methods for each of the user-facing overload
54  * sets in `BigQueryWriteClient`. This allows users to inject custom behavior
55  * (e.g., with a Google Mock object) when writing tests that use objects of type
56  * `BigQueryWriteClient`.
57  *
58  * To create a concrete instance, see `MakeBigQueryWriteConnection()`.
59  *
60  * For mocking, see `bigquery_mocks::MockBigQueryWriteConnection`.
61  */
63  public:
64  virtual ~BigQueryWriteConnection() = 0;
65 
66  virtual Options options() { return Options{}; }
67 
68  virtual StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
70  google::cloud::bigquery::storage::v1::CreateWriteStreamRequest const&
71  request);
72 
73  virtual std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
74  google::cloud::bigquery::storage::v1::AppendRowsRequest,
75  google::cloud::bigquery::storage::v1::AppendRowsResponse>>
77 
78  virtual StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
80  google::cloud::bigquery::storage::v1::GetWriteStreamRequest const&
81  request);
82 
83  virtual StatusOr<
84  google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse>
86  google::cloud::bigquery::storage::v1::FinalizeWriteStreamRequest const&
87  request);
88 
89  virtual StatusOr<
90  google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse>
92  BatchCommitWriteStreamsRequest const& request);
93 
94  virtual StatusOr<google::cloud::bigquery::storage::v1::FlushRowsResponse>
96  google::cloud::bigquery::storage::v1::FlushRowsRequest const& request);
97 };
98 
99 /**
100  * A factory function to construct an object of type `BigQueryWriteConnection`.
101  *
102  * The returned connection object should not be used directly; instead it
103  * should be passed as an argument to the constructor of BigQueryWriteClient,
104  * and that class used instead.
105  *
106  * The optional @p opts argument may be used to configure aspects of the
107  * returned `BigQueryWriteConnection`. Expected options are any of the types in
108  * the following option lists:
109  *
110  * - `google::cloud::CommonOptionList`
111  * - `google::cloud::GrpcOptionList`
112  * - `google::cloud::bigquery::BigQueryWritePolicyOptionList`
113  *
114  * @note Unrecognized options will be ignored. To debug issues with options set
115  * `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment and unexpected
116  * options will be logged.
117  *
118  * @param options (optional) Configure the `BigQueryWriteConnection` created by
119  * this function.
120  */
122  Options options = {});
123 
125 } // namespace bigquery
126 } // namespace cloud
127 } // namespace google
128 
129 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_BIGQUERY_WRITE_CONNECTION_H