Google Cloud BigQuery C++ Client  2.7.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/internal/async_read_write_stream_impl.h"
27 #include "google/cloud/options.h"
28 #include "google/cloud/status_or.h"
29 #include "google/cloud/version.h"
30 #include <memory>
31 
32 namespace google {
33 namespace cloud {
34 namespace bigquery {
36 
37 using BigQueryWriteRetryPolicy =
38  ::google::cloud::internal::TraitBasedRetryPolicy<
39  bigquery_internal::BigQueryWriteRetryTraits>;
40 
41 using BigQueryWriteLimitedTimeRetryPolicy =
42  ::google::cloud::internal::LimitedTimeRetryPolicy<
43  bigquery_internal::BigQueryWriteRetryTraits>;
44 
45 using BigQueryWriteLimitedErrorCountRetryPolicy =
46  ::google::cloud::internal::LimitedErrorCountRetryPolicy<
47  bigquery_internal::BigQueryWriteRetryTraits>;
48 
49 /**
50  * The `BigQueryWriteConnection` object for `BigQueryWriteClient`.
51  *
52  * This interface defines virtual methods for each of the user-facing overload
53  * sets in `BigQueryWriteClient`. This allows users to inject custom behavior
54  * (e.g., with a Google Mock object) when writing tests that use objects of type
55  * `BigQueryWriteClient`.
56  *
57  * To create a concrete instance, see `MakeBigQueryWriteConnection()`.
58  *
59  * For mocking, see `bigquery_mocks::MockBigQueryWriteConnection`.
60  */
62  public:
63  virtual ~BigQueryWriteConnection() = 0;
64 
65  virtual Options options() { return Options{}; }
66 
67  virtual StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
69  google::cloud::bigquery::storage::v1::CreateWriteStreamRequest const&
70  request);
71 
72  virtual std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
73  google::cloud::bigquery::storage::v1::AppendRowsRequest,
74  google::cloud::bigquery::storage::v1::AppendRowsResponse>>
76 
77  virtual StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
79  google::cloud::bigquery::storage::v1::GetWriteStreamRequest const&
80  request);
81 
82  virtual StatusOr<
83  google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse>
85  google::cloud::bigquery::storage::v1::FinalizeWriteStreamRequest const&
86  request);
87 
88  virtual StatusOr<
89  google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse>
91  BatchCommitWriteStreamsRequest const& request);
92 
93  virtual StatusOr<google::cloud::bigquery::storage::v1::FlushRowsResponse>
95  google::cloud::bigquery::storage::v1::FlushRowsRequest const& request);
96 };
97 
98 /**
99  * A factory function to construct an object of type `BigQueryWriteConnection`.
100  *
101  * The returned connection object should not be used directly; instead it
102  * should be passed as an argument to the constructor of BigQueryWriteClient.
103  *
104  * The optional @p options argument may be used to configure aspects of the
105  * returned `BigQueryWriteConnection`. Expected options are any of the types in
106  * the following option lists:
107  *
108  * - `google::cloud::CommonOptionList`
109  * - `google::cloud::GrpcOptionList`
110  * - `google::cloud::UnifiedCredentialsOptionList`
111  * - `google::cloud::bigquery::BigQueryWritePolicyOptionList`
112  *
113  * @note Unexpected options will be ignored. To log unexpected options instead,
114  * set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment.
115  *
116  * @param options (optional) Configure the `BigQueryWriteConnection` created by
117  * this function.
118  */
120  Options options = {});
121 
123 } // namespace bigquery
124 } // namespace cloud
125 } // namespace google
126 
127 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_BIGQUERY_WRITE_CONNECTION_H