Google Cloud Storage C++ Client
1.42.0
A C++ Client Library for Google Cloud Storage
options.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
// 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
#
ifndef
GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OPTIONS_H
16
#
define
GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OPTIONS_H
17
18
#
include
"google/cloud/storage/idempotency_policy.h"
19
#
include
"google/cloud/storage/oauth2/credentials.h"
20
#
include
"google/cloud/storage/retry_policy.h"
21
#
include
"google/cloud/storage/version.h"
22
#
include
"google/cloud/backoff_policy.h"
23
#
include
"google/cloud/credentials.h"
24
#
include
"google/cloud/options.h"
25
#
include
<
chrono
>
26
#
include
<
memory
>
27
#
include
<
string
>
28
29
namespace
google
{
30
namespace
cloud
{
31
namespace
storage_experimental
{
32
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
33
34
/**
35
* Set the HTTP version used by the client.
36
*
37
* If this option is not provided, or is set to `default` then the library uses
38
* [libcurl's default], typically HTTP/2 with SSL. Possible settings include:
39
* - "1.0": use HTTP/1.0, this is not recommended as would require a new
40
* connection for each request.
41
* - "1.1": use HTTP/1.1, this may be useful when the overhead of HTTP/2 is
42
* unacceptable. Note that this may require additional connections.
43
* - "2TLS": use HTTP/2 with TLS
44
* - "2.0": use HTTP/2 with our without TLS.
45
*
46
* [libcurl's default]: https://curl.se/libcurl/c/CURLOPT_HTTP_VERSION.html
47
*/
48
struct
HttpVersionOption
{
49
using
Type = std::string;
50
};
51
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
52
}
// namespace storage_experimental
53
54
namespace
storage
{
55
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
56
namespace
internal {
57
/// This is only intended for testing against staging or development versions
58
/// of the service. It is not for public use.
59
struct
TargetApiVersionOption {
60
using
Type = std::string;
61
};
62
63
/// This is only intended for testing. It is not for public use.
64
struct
CAPathOption {
65
using
Type = std::string;
66
};
67
68
/// This is only intended for testing of the library. Not for public use.
69
struct
UseRestClientOption {
70
using
Type =
bool
;
71
};
72
73
}
// namespace internal
74
75
/// Configure the REST endpoint for the GCS client library.
76
struct
RestEndpointOption
{
77
using
Type = std::string;
78
};
79
80
/// Configure the IAM endpoint for the GCS client library.
81
struct
IamEndpointOption
{
82
using
Type = std::string;
83
};
84
85
/// Configure oauth2::Credentials for the GCS client library.
86
struct
Oauth2CredentialsOption
{
87
using
Type = std::shared_ptr<
oauth2
::
Credentials
>;
88
};
89
90
/// Set the Google Cloud Platform project id.
91
struct
ProjectIdOption
{
92
using
Type = std::string;
93
};
94
95
/**
96
* Set the maximum connection pool size.
97
*
98
* The C++ client library uses this value to limit the growth of the
99
* connection pool. Once an operation (a RPC or a download) completes the
100
* connection used for that operation is returned to the pool. If the pool is
101
* full the connection is immediately released. If the pool has room the
102
* connection is cached for the next RPC or download.
103
*
104
* @note The behavior of this pool may change in the future, depending on the
105
* low-level implementation details of the library.
106
*
107
* @note The library does not create connections proactively, setting a high
108
* value may result in very few connections if your application does not need
109
* them.
110
*
111
* @note Setting this value to 0 disables connection pooling.
112
*
113
* @warning The library may create more connections than this option configures,
114
* for example if your application requests many simultaneous downloads.
115
*/
116
struct
ConnectionPoolSizeOption
{
117
using
Type = std::size_t;
118
};
119
120
/**
121
* Control the formatted I/O download buffer.
122
*
123
* When using formatted I/O operations (typically `operator>>(std::istream&...)`
124
* this option controls the size of the in-memory buffer kept to satisfy any I/O
125
* requests.
126
*
127
* Applications seeking optimal performance for downloads should avoid
128
* formatted I/O, and prefer using `std::istream::read()`. This option has no
129
* effect in that case.
130
*/
131
struct
DownloadBufferSizeOption
{
132
using
Type = std::size_t;
133
};
134
135
/**
136
* Control the formatted I/O upload buffer.
137
*
138
* When using formatted I/O operations (typically `operator<<(std::istream&...)`
139
* this option controls the size of the in-memory buffer kept before a chunk is
140
* uploaded. Note that GCS only accepts chunks in multiples of 256KiB, so this
141
* option is always rounded up to the next such multiple.
142
*
143
* Applications seeking optimal performance for downloads should avoid
144
* formatted I/O, and prefer using `std::istream::write()`. This option has no
145
* effect in that case.
146
*/
147
struct
UploadBufferSizeOption
{
148
using
Type = std::size_t;
149
};
150
151
/**
152
* Defines the threshold to switch from simple to resumable uploads for files.
153
*
154
* When uploading small files the faster approach is to use a simple upload. For
155
* very large files this is not feasible, as the whole file may not fit in
156
* memory (we are ignoring memory mapped files in this discussion). The library
157
* automatically switches to resumable upload for files larger than this
158
* threshold.
159
*/
160
struct
MaximumSimpleUploadSizeOption
{
161
using
Type = std::size_t;
162
};
163
164
/**
165
* Disables automatic OpenSSL locking.
166
*
167
* With older versions of OpenSSL any locking must be provided by locking
168
* callbacks in the application or intermediate libraries. The C++ client
169
* library automatically provides the locking callbacks. If your application
170
* already provides such callbacks, and you prefer to use them, set this option
171
* to `false`.
172
*
173
* @note This option is only useful for applications linking against
174
* OpenSSL 1.0.2.
175
*/
176
struct
EnableCurlSslLockingOption
{
177
using
Type =
bool
;
178
};
179
180
/**
181
* Disables automatic OpenSSL sigpipe handler.
182
*
183
* With some versions of OpenSSL it might be necessary to setup a SIGPIPE
184
* handler. If your application already provides such a handler, set this option
185
* to `false` to disable the handler in the GCS C++ client library.
186
*/
187
struct
EnableCurlSigpipeHandlerOption
{
188
using
Type =
bool
;
189
};
190
191
/**
192
* Control the maximum socket receive buffer.
193
*
194
* The default is to let the operating system pick a value. Applications that
195
* perform multiple downloads in parallel may need to use smaller receive
196
* buffers to avoid exhausting the OS resources dedicated to TCP buffers.
197
*/
198
struct
MaximumCurlSocketRecvSizeOption
{
199
using
Type = std::size_t;
200
};
201
202
/**
203
* Control the maximum socket send buffer.
204
*
205
* The default is to let the operating system pick a value, this is almost
206
* always a good choice.
207
*/
208
struct
MaximumCurlSocketSendSizeOption
{
209
using
Type = std::size_t;
210
};
211
212
/**
213
* Sets the transfer stall timeout.
214
*
215
* If a transfer (upload, download, or request) *stalls*, i.e., no bytes are
216
* sent or received for a significant period, it may be better to restart the
217
* transfer as this may indicate a network glitch. For downloads the
218
* google::cloud::storage::DownloadStallTimeoutOption takes precedence.
219
*
220
* For large requests (e.g. downloads in the GiB to TiB range) this is a better
221
* configuration parameter than a simple timeout, as the transfers will take
222
* minutes or hours to complete. Relying on a timeout value for them would not
223
* work, as the timeout would be too large to be useful. For small requests,
224
* this is as effective as a timeout parameter, but maybe unfamiliar and thus
225
* harder to reason about.
226
*/
227
struct
TransferStallTimeoutOption
{
228
using
Type = std::chrono::seconds;
229
};
230
231
/**
232
* Sets the download stall timeout.
233
*
234
* If a download *stalls*, i.e., no bytes are received for a significant period,
235
* it may be better to restart the download as this may indicate a network
236
* glitch.
237
*
238
* For large requests (e.g. downloads in the GiB to TiB range) this is a better
239
* configuration parameter than a simple timeout, as the transfers will take
240
* minutes or hours to complete. Relying on a timeout value for them would not
241
* work, as the timeout would be too large to be useful. For small requests,
242
* this is as effective as a timeout parameter, but maybe unfamiliar and thus
243
* harder to reason about.
244
*/
245
struct
DownloadStallTimeoutOption
{
246
using
Type = std::chrono::seconds;
247
};
248
249
/// Set the retry policy for a GCS client.
250
struct
RetryPolicyOption
{
251
using
Type = std::shared_ptr<RetryPolicy>;
252
};
253
254
/// Set the backoff policy for a GCS client.
255
struct
BackoffPolicyOption
{
256
using
Type = std::shared_ptr<BackoffPolicy>;
257
};
258
259
/// Set the idempotency policy for a GCS client.
260
struct
IdempotencyPolicyOption
{
261
using
Type = std::shared_ptr<
IdempotencyPolicy
>;
262
};
263
264
/// The complete list of options accepted by `storage::Client`.
265
using
ClientOptionList = ::
google
::
cloud
::OptionList<
266
RestEndpointOption
,
IamEndpointOption
,
Oauth2CredentialsOption
,
267
ProjectIdOption
,
ProjectIdOption
,
ConnectionPoolSizeOption
,
268
DownloadBufferSizeOption
,
UploadBufferSizeOption
,
269
EnableCurlSslLockingOption
,
EnableCurlSigpipeHandlerOption
,
270
MaximumCurlSocketRecvSizeOption
,
MaximumCurlSocketSendSizeOption
,
271
TransferStallTimeoutOption
,
RetryPolicyOption
,
BackoffPolicyOption
,
272
IdempotencyPolicyOption
,
CARootsFilePathOption
,
273
storage_experimental
::
HttpVersionOption
>;
274
275
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
276
}
// namespace storage
277
}
// namespace cloud
278
}
// namespace google
279
280
#
endif
// GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OPTIONS_H
Generated on Thu Sep 15 2022 21:57:18 for Google Cloud Storage C++ Client by
1.9.1