couchbase 3.2.0 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -18
- package/binding.gyp +88 -85
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +99 -14
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/CMakeLists.txt +4 -4
- package/deps/lcb/example/libuvdirect/main.c +39 -12
- package/deps/lcb/example/minimal/durability.cc +149 -0
- package/deps/lcb/example/minimal/query.c +11 -9
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
- package/deps/lcb/include/libcouchbase/error.h +2 -0
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +347 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
- package/deps/lcb/src/bootstrap.cc +6 -3
- package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
- package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
- package/deps/lcb/src/capi/cmd_counter.hh +23 -0
- package/deps/lcb/src/capi/cmd_exists.hh +24 -1
- package/deps/lcb/src/capi/cmd_get.hh +22 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
- package/deps/lcb/src/capi/cmd_http.hh +7 -0
- package/deps/lcb/src/capi/cmd_query.cc +11 -1
- package/deps/lcb/src/capi/cmd_query.hh +31 -0
- package/deps/lcb/src/capi/cmd_remove.hh +23 -0
- package/deps/lcb/src/capi/cmd_search.cc +6 -0
- package/deps/lcb/src/capi/cmd_search.hh +23 -0
- package/deps/lcb/src/capi/cmd_store.hh +33 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
- package/deps/lcb/src/capi/cmd_touch.hh +23 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
- package/deps/lcb/src/cntl.cc +45 -11
- package/deps/lcb/src/crypto.cc +2 -2
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/hostlist.h +2 -2
- package/deps/lcb/src/http/http-priv.h +2 -2
- package/deps/lcb/src/http/http.cc +5 -2
- package/deps/lcb/src/instance.cc +20 -11
- package/deps/lcb/src/internal.h +9 -0
- package/deps/lcb/src/lcbio/connect.cc +14 -2
- package/deps/lcb/src/lcbio/connect.h +2 -2
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/lcbio/ioutils.cc +9 -10
- package/deps/lcb/src/lcbio/manager.cc +1 -1
- package/deps/lcb/src/mcserver/mcserver.cc +9 -6
- package/deps/lcb/src/mcserver/negotiate.cc +39 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/query_handle.cc +41 -19
- package/deps/lcb/src/n1ql/query_handle.hh +28 -1
- package/deps/lcb/src/operations/counter.cc +18 -5
- package/deps/lcb/src/operations/exists.cc +25 -4
- package/deps/lcb/src/operations/get.cc +39 -19
- package/deps/lcb/src/operations/get_replica.cc +28 -8
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/ping.cc +8 -8
- package/deps/lcb/src/operations/pktfwd.cc +2 -1
- package/deps/lcb/src/operations/remove.cc +39 -22
- package/deps/lcb/src/operations/store.cc +18 -5
- package/deps/lcb/src/operations/subdoc.cc +18 -6
- package/deps/lcb/src/operations/touch.cc +34 -16
- package/deps/lcb/src/operations/unlock.cc +24 -5
- package/deps/lcb/src/packetutils.h +3 -2
- package/deps/lcb/src/retryq.cc +24 -5
- package/deps/lcb/src/search/search.cc +1 -0
- package/deps/lcb/src/search/search_handle.cc +30 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/settings.cc +1 -1
- package/deps/lcb/src/ssl/ssl_common.c +6 -7
- package/deps/lcb/src/tracing/span.cc +47 -14
- package/deps/lcb/src/tracing/tracer.cc +11 -2
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +43 -0
- package/deps/lcb/src/utilities.h +53 -0
- package/deps/lcb/src/vbucket/vbucket.c +34 -33
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -0
- package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
- package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +109 -7
- package/deps/lcb/tests/iotests/t_http.cc +9 -4
- package/deps/lcb/tests/iotests/t_lock.cc +18 -0
- package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
- package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +168 -0
- package/deps/lcb/tests/iotests/testutil.h +116 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tests/mocksupport/timeout.c +2 -2
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binding.d.ts +3 -0
- package/dist/bindingutilities.js +4 -0
- package/dist/bucket.js +1 -1
- package/dist/bucketmanager.d.ts +31 -1
- package/dist/bucketmanager.js +194 -186
- package/dist/cluster.d.ts +7 -0
- package/dist/cluster.js +48 -38
- package/dist/collection.js +11 -17
- package/dist/collectionmanager.js +181 -197
- package/dist/connection.d.ts +3 -1
- package/dist/connection.js +27 -16
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +3 -13
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +70 -0
- package/dist/errors.js +96 -2
- package/dist/eventingfunctionmanager.d.ts +804 -0
- package/dist/eventingfunctionmanager.js +993 -0
- package/dist/httpexecutor.d.ts +2 -1
- package/dist/httpexecutor.js +30 -37
- package/dist/queryindexmanager.js +240 -266
- package/dist/scope.js +10 -4
- package/dist/sdspecs.d.ts +1 -1
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +251 -264
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +7 -2
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/addondata.cpp +58 -0
- package/src/addondata.h +40 -0
- package/src/binding.cpp +3 -1
- package/src/cas.h +2 -2
- package/src/connection.cpp +25 -178
- package/src/connection.h +8 -65
- package/src/connection_ops.cpp +57 -34
- package/src/constants.cpp +3 -0
- package/src/instance.cpp +235 -0
- package/src/instance.h +102 -0
- package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
- package/src/logger.cpp +11 -1
- package/src/logger.h +3 -0
- package/src/metrics.cpp +10 -0
- package/src/metrics.h +3 -0
- package/src/mutationtoken.h +2 -2
- package/src/opbuilder.h +13 -15
- package/src/respreader.cpp +1 -0
- package/src/respreader.h +6 -4
- package/src/tracespan.h +11 -11
- package/src/tracing.cpp +11 -0
- package/src/tracing.h +3 -0
- package/src/valueparser.h +5 -0
- package/deps/lcb/example/observe/durability.c +0 -110
|
@@ -6,7 +6,7 @@ Standards-Version: 3.9.2
|
|
|
6
6
|
Section: libs
|
|
7
7
|
Homepage: http://www.couchbase.com/develop/c/current
|
|
8
8
|
Vcs-Browser: https://github.com/couchbase/libcouchbase
|
|
9
|
-
Vcs-Git:
|
|
9
|
+
Vcs-Git: https://github.com/couchbase/libcouchbase.git
|
|
10
10
|
|
|
11
11
|
Package: libcouchbase3-libevent
|
|
12
12
|
Architecture: any
|
|
@@ -225,7 +225,7 @@ lcb_ANALYTICS_HANDLE_::lcb_ANALYTICS_HANDLE_(lcb_INSTANCE *obj, void *user_cooki
|
|
|
225
225
|
query_params_ = Json::FastWriter().write(cmd->root());
|
|
226
226
|
|
|
227
227
|
if (instance_->settings->tracer) {
|
|
228
|
-
|
|
228
|
+
parent_span_ = cmd->parent_span();
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
if (ingest_options().method != LCB_INGEST_METHOD_NONE) {
|
|
@@ -237,6 +237,9 @@ lcb_ANALYTICS_HANDLE_::lcb_ANALYTICS_HANDLE_(lcb_INSTANCE *obj, void *user_cooki
|
|
|
237
237
|
// TODO: docq->max_pending_response;
|
|
238
238
|
lcb_aspend_add(&instance_->pendops, LCB_PENDTYPE_COUNTER, nullptr);
|
|
239
239
|
}
|
|
240
|
+
if (cmd->want_impersonation()) {
|
|
241
|
+
impostor_ = cmd->impostor();
|
|
242
|
+
}
|
|
240
243
|
}
|
|
241
244
|
|
|
242
245
|
lcb_ANALYTICS_HANDLE_::lcb_ANALYTICS_HANDLE_(lcb_INSTANCE *obj, void *user_cookie, lcb_DEFERRED_HANDLE *handle)
|
|
@@ -277,9 +280,11 @@ lcb_STATUS lcb_ANALYTICS_HANDLE_::issue_htreq(const std::string &body)
|
|
|
277
280
|
if (!hostname.empty()) {
|
|
278
281
|
lcb_cmdhttp_host(htcmd, hostname.c_str(), hostname.size());
|
|
279
282
|
}
|
|
283
|
+
if (!impostor_.empty()) {
|
|
284
|
+
htcmd->set_header("cb-on-behalf-of", impostor_);
|
|
285
|
+
}
|
|
280
286
|
|
|
281
|
-
|
|
282
|
-
LCBTRACE_THRESHOLD_ANALYTICS, span_);
|
|
287
|
+
span_ = lcb::trace::start_http_span_with_statement(instance_->settings, this, statement_);
|
|
283
288
|
lcb_cmdhttp_parent_span(htcmd, span_);
|
|
284
289
|
|
|
285
290
|
lcb_STATUS rc = lcb_http(instance_, this, htcmd);
|
|
@@ -388,7 +393,7 @@ void lcb_ANALYTICS_HANDLE_::invoke_row(lcb_RESPANALYTICS *resp, bool is_last)
|
|
|
388
393
|
resp->rflags |= LCB_RESP_F_EXTDATA;
|
|
389
394
|
}
|
|
390
395
|
Json::Value meta;
|
|
391
|
-
if (Json::Reader().parse(resp->row, resp->row + resp->nrow, meta)) {
|
|
396
|
+
if (Json::Reader(Json::Features::strictMode()).parse(resp->row, resp->row + resp->nrow, meta)) {
|
|
392
397
|
const Json::Value &errors = meta["errors"];
|
|
393
398
|
if (errors.isArray() && !errors.empty()) {
|
|
394
399
|
const Json::Value &err = errors[0];
|
|
@@ -450,7 +455,10 @@ void lcb_ANALYTICS_HANDLE_::invoke_row(lcb_RESPANALYTICS *resp, bool is_last)
|
|
|
450
455
|
}
|
|
451
456
|
}
|
|
452
457
|
|
|
453
|
-
|
|
458
|
+
if (span_ != nullptr) {
|
|
459
|
+
lcb::trace::finish_http_span(span_, this);
|
|
460
|
+
span_ = nullptr;
|
|
461
|
+
}
|
|
454
462
|
if (http_request_ != nullptr) {
|
|
455
463
|
http_request_->span = nullptr;
|
|
456
464
|
}
|
|
@@ -208,6 +208,32 @@ struct lcb_ANALYTICS_HANDLE_ : lcb::jsparse::Parser::Actions {
|
|
|
208
208
|
return last_error_;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
static lcbtrace_THRESHOLDOPTS service()
|
|
212
|
+
{
|
|
213
|
+
return LCBTRACE_THRESHOLD_ANALYTICS;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
static const std::string &operation_name()
|
|
217
|
+
{
|
|
218
|
+
static std::string name = LCBTRACE_OP_ANALYTICS;
|
|
219
|
+
return name;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
lcbtrace_SPAN *parent_span() const
|
|
223
|
+
{
|
|
224
|
+
return parent_span_;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const std::string &client_context_id() const
|
|
228
|
+
{
|
|
229
|
+
return client_context_id_;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
int retries() const
|
|
233
|
+
{
|
|
234
|
+
return retries_;
|
|
235
|
+
}
|
|
236
|
+
|
|
211
237
|
private:
|
|
212
238
|
const lcb_RESPHTTP *http_response_{nullptr};
|
|
213
239
|
lcb_HTTP_HANDLE *http_request_{nullptr};
|
|
@@ -219,6 +245,7 @@ struct lcb_ANALYTICS_HANDLE_ : lcb::jsparse::Parser::Actions {
|
|
|
219
245
|
lcb_U32 timeout_{0};
|
|
220
246
|
// How many rows were received. Used to avoid parsing the meta
|
|
221
247
|
size_t rows_number_{0};
|
|
248
|
+
int retries_{0};
|
|
222
249
|
|
|
223
250
|
/** Request body as received from the application */
|
|
224
251
|
Json::Value json{};
|
|
@@ -240,7 +267,9 @@ struct lcb_ANALYTICS_HANDLE_ : lcb::jsparse::Parser::Actions {
|
|
|
240
267
|
lcb::docreq::Queue *document_queue_{nullptr};
|
|
241
268
|
unsigned refcount{1};
|
|
242
269
|
|
|
270
|
+
lcbtrace_SPAN *parent_span_{nullptr};
|
|
243
271
|
lcbtrace_SPAN *span_{nullptr};
|
|
272
|
+
std::string impostor_{};
|
|
244
273
|
};
|
|
245
274
|
|
|
246
275
|
#endif // LIBCOUCHBASE_ANALYTICS_HANDLE_HH
|
|
@@ -37,8 +37,11 @@ void Bootstrap::config_callback(EventType event, ConfigInfo *info)
|
|
|
37
37
|
lcb_INSTANCE *instance = parent;
|
|
38
38
|
|
|
39
39
|
if (event != CLCONFIG_EVENT_GOT_NEW_CONFIG) {
|
|
40
|
-
if (event == CLCONFIG_EVENT_PROVIDERS_CYCLED) {
|
|
41
|
-
if (
|
|
40
|
+
if (event == CLCONFIG_EVENT_PROVIDERS_CYCLED && !LCBT_VBCONFIG(instance)) {
|
|
41
|
+
if (parent->confmon->get_last_error() == LCB_ERR_CONNECTION_REFUSED) {
|
|
42
|
+
initial_error(LCB_ERR_NO_MATCHING_SERVER,
|
|
43
|
+
"Unable to bootstrap, check ports and cluster encryption setting");
|
|
44
|
+
} else {
|
|
42
45
|
initial_error(LCB_ERR_NO_MATCHING_SERVER, "No more bootstrap providers remain");
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -199,7 +202,7 @@ void Bootstrap::initial_error(lcb_STATUS err, const char *errinfo)
|
|
|
199
202
|
if (parent->last_error == LCB_SUCCESS) {
|
|
200
203
|
parent->last_error = err;
|
|
201
204
|
}
|
|
202
|
-
lcb_log(LOGARGS(parent, ERR), "Failed to bootstrap client=%p. Error=%s (Last=%s), Message
|
|
205
|
+
lcb_log(LOGARGS(parent, ERR), "Failed to bootstrap client=%p. Error=%s (Last=%s), Message=\"%s\"", (void *)parent,
|
|
203
206
|
lcb_strerror_short(err), lcb_strerror_short(parent->last_error), errinfo);
|
|
204
207
|
tm.cancel();
|
|
205
208
|
|
|
@@ -222,10 +222,16 @@ LIBCOUCHBASE_API lcb_STATUS lcb_cmdanalytics_named_param(lcb_CMDANALYTICS *cmd,
|
|
|
222
222
|
return cmd->option(name, name_len, value, value_len);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
LIBCOUCHBASE_API lcb_STATUS lcb_cmdanalytics_positional_params(lcb_CMDANALYTICS *cmd, const char *value,
|
|
226
|
+
size_t value_len)
|
|
227
|
+
{
|
|
228
|
+
return cmd->option_array("args", value, value_len);
|
|
229
|
+
}
|
|
230
|
+
|
|
225
231
|
LIBCOUCHBASE_API lcb_STATUS lcb_cmdanalytics_positional_param(lcb_CMDANALYTICS *cmd, const char *value,
|
|
226
232
|
size_t value_len)
|
|
227
233
|
{
|
|
228
|
-
return cmd->
|
|
234
|
+
return cmd->option_array_append("args", value, value_len);
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
LIBCOUCHBASE_API lcb_STATUS lcb_cmdanalytics_deferred(lcb_CMDANALYTICS *cmd, int deferred)
|
|
@@ -238,6 +244,11 @@ LIBCOUCHBASE_API lcb_STATUS lcb_cmdanalytics_ingest_options(lcb_CMDANALYTICS *cm
|
|
|
238
244
|
return cmd->ingest_options(options);
|
|
239
245
|
}
|
|
240
246
|
|
|
247
|
+
LIBCOUCHBASE_API lcb_STATUS lcb_cmdanalytics_on_behalf_of(lcb_CMDANALYTICS *cmd, const char *data, size_t data_len)
|
|
248
|
+
{
|
|
249
|
+
return cmd->on_behalf_of(std::string(data, data_len));
|
|
250
|
+
}
|
|
251
|
+
|
|
241
252
|
LIBCOUCHBASE_API lcb_STATUS lcb_ingest_options_create(lcb_INGEST_OPTIONS **options)
|
|
242
253
|
{
|
|
243
254
|
*options = new lcb_INGEST_OPTIONS();
|
|
@@ -222,6 +222,19 @@ struct lcb_CMDANALYTICS_ {
|
|
|
222
222
|
return LCB_SUCCESS;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
lcb_STATUS option_array_append(const std::string &name, const char *value, std::size_t value_len)
|
|
226
|
+
{
|
|
227
|
+
if (name.empty() || value == nullptr) {
|
|
228
|
+
return LCB_ERR_INVALID_ARGUMENT;
|
|
229
|
+
}
|
|
230
|
+
Json::Value json_value;
|
|
231
|
+
if (!Json::Reader().parse(value, value + value_len, json_value)) {
|
|
232
|
+
return LCB_ERR_INVALID_ARGUMENT;
|
|
233
|
+
}
|
|
234
|
+
root_[name].append(json_value);
|
|
235
|
+
return LCB_SUCCESS;
|
|
236
|
+
}
|
|
237
|
+
|
|
225
238
|
lcb_STATUS option_string(const std::string &name, const char *value, std::size_t value_len)
|
|
226
239
|
{
|
|
227
240
|
if (name.empty() || value == nullptr || value_len == 0) {
|
|
@@ -346,6 +359,22 @@ struct lcb_CMDANALYTICS_ {
|
|
|
346
359
|
return priority_;
|
|
347
360
|
}
|
|
348
361
|
|
|
362
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
363
|
+
{
|
|
364
|
+
impostor_ = std::move(user);
|
|
365
|
+
return LCB_SUCCESS;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
bool want_impersonation() const
|
|
369
|
+
{
|
|
370
|
+
return !impostor_.empty();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const std::string &impostor() const
|
|
374
|
+
{
|
|
375
|
+
return impostor_;
|
|
376
|
+
}
|
|
377
|
+
|
|
349
378
|
private:
|
|
350
379
|
std::chrono::microseconds timeout_{0};
|
|
351
380
|
std::chrono::nanoseconds start_time_{0};
|
|
@@ -359,6 +388,7 @@ struct lcb_CMDANALYTICS_ {
|
|
|
359
388
|
bool priority_{false};
|
|
360
389
|
std::string scope_qualifier_{};
|
|
361
390
|
std::string scope_name_{};
|
|
391
|
+
std::string impostor_{};
|
|
362
392
|
};
|
|
363
393
|
|
|
364
394
|
#endif // LIBCOUCHBASE_CAPI_ANALYTICS_HH
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
*/
|
|
31
31
|
struct lcb_CMDCOUNTER_ {
|
|
32
32
|
public:
|
|
33
|
+
static const std::string &operation_name()
|
|
34
|
+
{
|
|
35
|
+
static std::string name = LCBTRACE_OP_COUNTER;
|
|
36
|
+
return name;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
lcb_STATUS expiry(std::uint32_t expiry)
|
|
34
40
|
{
|
|
35
41
|
if (!initialize_if_does_not_exist_) {
|
|
@@ -175,6 +181,22 @@ struct lcb_CMDCOUNTER_ {
|
|
|
175
181
|
return cookie_;
|
|
176
182
|
}
|
|
177
183
|
|
|
184
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
185
|
+
{
|
|
186
|
+
impostor_ = std::move(user);
|
|
187
|
+
return LCB_SUCCESS;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
bool want_impersonation() const
|
|
191
|
+
{
|
|
192
|
+
return !impostor_.empty();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const std::string &impostor() const
|
|
196
|
+
{
|
|
197
|
+
return impostor_;
|
|
198
|
+
}
|
|
199
|
+
|
|
178
200
|
private:
|
|
179
201
|
lcb::collection_qualifier collection_{};
|
|
180
202
|
std::uint32_t expiry_{0};
|
|
@@ -187,6 +209,7 @@ struct lcb_CMDCOUNTER_ {
|
|
|
187
209
|
std::string key_{};
|
|
188
210
|
bool initialize_if_does_not_exist_{false};
|
|
189
211
|
lcb_DURABILITY_LEVEL durability_level_{LCB_DURABILITYLEVEL_NONE};
|
|
212
|
+
std::string impostor_{};
|
|
190
213
|
};
|
|
191
214
|
|
|
192
215
|
/**
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
* @private
|
|
29
29
|
*/
|
|
30
30
|
struct lcb_CMDEXISTS_ {
|
|
31
|
+
static const std::string &operation_name()
|
|
32
|
+
{
|
|
33
|
+
static std::string name = LCBTRACE_OP_EXISTS;
|
|
34
|
+
return name;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
lcb_STATUS key(std::string key)
|
|
32
38
|
{
|
|
33
39
|
key_ = std::move(key);
|
|
@@ -115,13 +121,30 @@ struct lcb_CMDEXISTS_ {
|
|
|
115
121
|
return cookie_;
|
|
116
122
|
}
|
|
117
123
|
|
|
124
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
125
|
+
{
|
|
126
|
+
impostor_ = std::move(user);
|
|
127
|
+
return LCB_SUCCESS;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
bool want_impersonation() const
|
|
131
|
+
{
|
|
132
|
+
return !impostor_.empty();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const std::string &impostor() const
|
|
136
|
+
{
|
|
137
|
+
return impostor_;
|
|
138
|
+
}
|
|
139
|
+
|
|
118
140
|
private:
|
|
119
141
|
lcb::collection_qualifier collection_{};
|
|
120
142
|
std::chrono::microseconds timeout_{0};
|
|
121
143
|
std::chrono::nanoseconds start_time_{0};
|
|
122
144
|
lcbtrace_SPAN *parent_span_{nullptr};
|
|
123
|
-
void *cookie_;
|
|
145
|
+
void *cookie_{nullptr};
|
|
124
146
|
std::string key_{};
|
|
147
|
+
std::string impostor_{};
|
|
125
148
|
};
|
|
126
149
|
|
|
127
150
|
/**
|
|
@@ -34,6 +34,11 @@ enum class get_mode {
|
|
|
34
34
|
* @private
|
|
35
35
|
*/
|
|
36
36
|
struct lcb_CMDGET_ {
|
|
37
|
+
static const std::string &operation_name()
|
|
38
|
+
{
|
|
39
|
+
static std::string name = LCBTRACE_OP_GET;
|
|
40
|
+
return name;
|
|
41
|
+
}
|
|
37
42
|
|
|
38
43
|
lcb_STATUS with_touch(std::uint32_t expiry)
|
|
39
44
|
{
|
|
@@ -175,6 +180,22 @@ struct lcb_CMDGET_ {
|
|
|
175
180
|
return cookie_is_callback_;
|
|
176
181
|
}
|
|
177
182
|
|
|
183
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
184
|
+
{
|
|
185
|
+
impostor_ = std::move(user);
|
|
186
|
+
return LCB_SUCCESS;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
bool want_impersonation() const
|
|
190
|
+
{
|
|
191
|
+
return !impostor_.empty();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const std::string &impostor() const
|
|
195
|
+
{
|
|
196
|
+
return impostor_;
|
|
197
|
+
}
|
|
198
|
+
|
|
178
199
|
private:
|
|
179
200
|
lcb::collection_qualifier collection_{};
|
|
180
201
|
std::chrono::microseconds timeout_{0};
|
|
@@ -186,6 +207,7 @@ struct lcb_CMDGET_ {
|
|
|
186
207
|
std::string key_{};
|
|
187
208
|
get_mode mode_{get_mode::normal};
|
|
188
209
|
bool cookie_is_callback_{false};
|
|
210
|
+
std::string impostor_{};
|
|
189
211
|
};
|
|
190
212
|
|
|
191
213
|
/** @private */
|
|
@@ -36,6 +36,12 @@ enum class get_replica_mode {
|
|
|
36
36
|
* @private
|
|
37
37
|
*/
|
|
38
38
|
struct lcb_CMDGETREPLICA_ {
|
|
39
|
+
static const std::string &operation_name()
|
|
40
|
+
{
|
|
41
|
+
static std::string name = LCBTRACE_OP_GET_FROM_REPLICA;
|
|
42
|
+
return name;
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
lcb_STATUS mode(get_replica_mode mode)
|
|
40
46
|
{
|
|
41
47
|
mode_ = mode;
|
|
@@ -150,6 +156,22 @@ struct lcb_CMDGETREPLICA_ {
|
|
|
150
156
|
return cookie_;
|
|
151
157
|
}
|
|
152
158
|
|
|
159
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
160
|
+
{
|
|
161
|
+
impostor_ = std::move(user);
|
|
162
|
+
return LCB_SUCCESS;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
bool want_impersonation() const
|
|
166
|
+
{
|
|
167
|
+
return !impostor_.empty();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const std::string &impostor() const
|
|
171
|
+
{
|
|
172
|
+
return impostor_;
|
|
173
|
+
}
|
|
174
|
+
|
|
153
175
|
private:
|
|
154
176
|
lcb::collection_qualifier collection_{};
|
|
155
177
|
std::chrono::microseconds timeout_{0};
|
|
@@ -159,6 +181,7 @@ struct lcb_CMDGETREPLICA_ {
|
|
|
159
181
|
std::string key_{};
|
|
160
182
|
get_replica_mode mode_{get_replica_mode::any};
|
|
161
183
|
int select_index_{0};
|
|
184
|
+
std::string impostor_{};
|
|
162
185
|
};
|
|
163
186
|
|
|
164
187
|
struct lcb_RESPGETREPLICA_ {
|
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
* Note that the key and nkey fields indicate the _path_ for the API
|
|
51
51
|
*/
|
|
52
52
|
struct lcb_CMDHTTP_ {
|
|
53
|
+
void set_header(const std::string &name, const std::string &value)
|
|
54
|
+
{
|
|
55
|
+
headers_.emplace(name, value);
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
/**Common flags for the command. These modify the command itself. Currently
|
|
54
59
|
the lower 16 bits of this field are reserved, and the higher 16 bits are
|
|
55
60
|
used for individual commands.*/
|
|
@@ -118,6 +123,8 @@ struct lcb_CMDHTTP_ {
|
|
|
118
123
|
/** If set, this must be a string in the form of `http://host:port`. Should
|
|
119
124
|
* only be used for raw requests. */
|
|
120
125
|
const char *host;
|
|
126
|
+
|
|
127
|
+
std::map<std::string, std::string> headers_{};
|
|
121
128
|
};
|
|
122
129
|
|
|
123
130
|
/**
|
|
@@ -142,11 +142,16 @@ LIBCOUCHBASE_API lcb_STATUS lcb_cmdquery_named_param(lcb_CMDQUERY *cmd, const ch
|
|
|
142
142
|
return cmd->option("$" + std::string(name, name_len), value, value_len);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
LIBCOUCHBASE_API lcb_STATUS
|
|
145
|
+
LIBCOUCHBASE_API lcb_STATUS lcb_cmdquery_positional_params(lcb_CMDQUERY *cmd, const char *value, size_t value_len)
|
|
146
146
|
{
|
|
147
147
|
return cmd->option_array("args", value, value_len);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
LIBCOUCHBASE_API lcb_STATUS lcb_cmdquery_positional_param(lcb_CMDQUERY *cmd, const char *value, size_t value_len)
|
|
151
|
+
{
|
|
152
|
+
return cmd->option_array_append("args", value, value_len);
|
|
153
|
+
}
|
|
154
|
+
|
|
150
155
|
LIBCOUCHBASE_API lcb_STATUS lcb_cmdquery_adhoc(lcb_CMDQUERY *cmd, int adhoc)
|
|
151
156
|
{
|
|
152
157
|
return cmd->prepare_statement(!adhoc);
|
|
@@ -258,6 +263,11 @@ LIBCOUCHBASE_API lcb_STATUS lcb_cmdquery_handle(lcb_CMDQUERY *cmd, lcb_QUERY_HAN
|
|
|
258
263
|
return cmd->store_handle_refence_to(handle);
|
|
259
264
|
}
|
|
260
265
|
|
|
266
|
+
LIBCOUCHBASE_API lcb_STATUS lcb_cmdquery_on_behalf_of(lcb_CMDQUERY *cmd, const char *data, size_t data_len)
|
|
267
|
+
{
|
|
268
|
+
return cmd->on_behalf_of(std::string(data, data_len));
|
|
269
|
+
}
|
|
270
|
+
|
|
261
271
|
LIBCOUCHBASE_API lcb_STATUS lcb_errctx_query_rc(const lcb_QUERY_ERROR_CONTEXT *ctx)
|
|
262
272
|
{
|
|
263
273
|
return ctx->rc;
|
|
@@ -381,6 +381,19 @@ struct lcb_CMDQUERY_ {
|
|
|
381
381
|
return LCB_SUCCESS;
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
+
lcb_STATUS option_array_append(const std::string &name, const char *value, std::size_t value_len)
|
|
385
|
+
{
|
|
386
|
+
if (name.empty() || value == nullptr) {
|
|
387
|
+
return LCB_ERR_INVALID_ARGUMENT;
|
|
388
|
+
}
|
|
389
|
+
Json::Value json_value;
|
|
390
|
+
if (!Json::Reader().parse(value, value + value_len, json_value)) {
|
|
391
|
+
return LCB_ERR_INVALID_ARGUMENT;
|
|
392
|
+
}
|
|
393
|
+
root_[name].append(json_value);
|
|
394
|
+
return LCB_SUCCESS;
|
|
395
|
+
}
|
|
396
|
+
|
|
384
397
|
lcb_STATUS option_string(const std::string &name, const char *value, std::size_t value_len)
|
|
385
398
|
{
|
|
386
399
|
if (name.empty() || value == nullptr || value_len == 0) {
|
|
@@ -417,6 +430,22 @@ struct lcb_CMDQUERY_ {
|
|
|
417
430
|
cookie_ = cookie;
|
|
418
431
|
}
|
|
419
432
|
|
|
433
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
434
|
+
{
|
|
435
|
+
impostor_ = std::move(user);
|
|
436
|
+
return LCB_SUCCESS;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
bool want_impersonation() const
|
|
440
|
+
{
|
|
441
|
+
return !impostor_.empty();
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const std::string &impostor() const
|
|
445
|
+
{
|
|
446
|
+
return impostor_;
|
|
447
|
+
}
|
|
448
|
+
|
|
420
449
|
private:
|
|
421
450
|
std::string scope_{};
|
|
422
451
|
std::string scope_qualifier_{};
|
|
@@ -450,6 +479,8 @@ struct lcb_CMDQUERY_ {
|
|
|
450
479
|
/**Request handle. Will be set to the handle which may be passed to
|
|
451
480
|
* lcb_query_cancel() */
|
|
452
481
|
lcb_QUERY_HANDLE **handle_{nullptr};
|
|
482
|
+
|
|
483
|
+
std::string impostor_{};
|
|
453
484
|
};
|
|
454
485
|
|
|
455
486
|
/**
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
* @private
|
|
29
29
|
*/
|
|
30
30
|
struct lcb_CMDREMOVE_ {
|
|
31
|
+
static const std::string &operation_name()
|
|
32
|
+
{
|
|
33
|
+
static std::string name = LCBTRACE_OP_REMOVE;
|
|
34
|
+
return name;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
lcb_STATUS cas(std::uint64_t cas)
|
|
32
38
|
{
|
|
33
39
|
cas_ = cas;
|
|
@@ -142,6 +148,22 @@ struct lcb_CMDREMOVE_ {
|
|
|
142
148
|
return cookie_;
|
|
143
149
|
}
|
|
144
150
|
|
|
151
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
152
|
+
{
|
|
153
|
+
impostor_ = std::move(user);
|
|
154
|
+
return LCB_SUCCESS;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
bool want_impersonation() const
|
|
158
|
+
{
|
|
159
|
+
return !impostor_.empty();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const std::string &impostor() const
|
|
163
|
+
{
|
|
164
|
+
return impostor_;
|
|
165
|
+
}
|
|
166
|
+
|
|
145
167
|
private:
|
|
146
168
|
lcb::collection_qualifier collection_{};
|
|
147
169
|
std::chrono::microseconds timeout_{0};
|
|
@@ -151,6 +173,7 @@ struct lcb_CMDREMOVE_ {
|
|
|
151
173
|
std::string key_{};
|
|
152
174
|
std::uint64_t cas_{0};
|
|
153
175
|
lcb_DURABILITY_LEVEL durability_level_{LCB_DURABILITYLEVEL_NONE};
|
|
176
|
+
std::string impostor_{};
|
|
154
177
|
};
|
|
155
178
|
|
|
156
179
|
/**
|
|
@@ -97,6 +97,12 @@ LIBCOUCHBASE_API lcb_STATUS lcb_cmdsearch_handle(lcb_CMDSEARCH *cmd, lcb_SEARCH_
|
|
|
97
97
|
{
|
|
98
98
|
return cmd->store_handle_refence_to(handle);
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
LIBCOUCHBASE_API lcb_STATUS lcb_cmdsearch_on_behalf_of(lcb_CMDSEARCH *cmd, const char *data, size_t data_len)
|
|
102
|
+
{
|
|
103
|
+
return cmd->on_behalf_of(std::string(data, data_len));
|
|
104
|
+
}
|
|
105
|
+
|
|
100
106
|
LIBCOUCHBASE_API lcb_STATUS lcb_errctx_search_rc(const lcb_SEARCH_ERROR_CONTEXT *ctx)
|
|
101
107
|
{
|
|
102
108
|
return ctx->rc;
|
|
@@ -70,6 +70,12 @@ struct lcb_RESPSEARCH_ {
|
|
|
70
70
|
* @private
|
|
71
71
|
*/
|
|
72
72
|
struct lcb_CMDSEARCH_ {
|
|
73
|
+
static const std::string &operation_name()
|
|
74
|
+
{
|
|
75
|
+
static std::string name = LCBTRACE_OP_SEARCH;
|
|
76
|
+
return name;
|
|
77
|
+
}
|
|
78
|
+
|
|
73
79
|
bool has_callback() const
|
|
74
80
|
{
|
|
75
81
|
return callback_ != nullptr;
|
|
@@ -168,6 +174,22 @@ struct lcb_CMDSEARCH_ {
|
|
|
168
174
|
return LCB_SUCCESS;
|
|
169
175
|
}
|
|
170
176
|
|
|
177
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
178
|
+
{
|
|
179
|
+
impostor_ = std::move(user);
|
|
180
|
+
return LCB_SUCCESS;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
bool want_impersonation() const
|
|
184
|
+
{
|
|
185
|
+
return !impostor_.empty();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const std::string &impostor() const
|
|
189
|
+
{
|
|
190
|
+
return impostor_;
|
|
191
|
+
}
|
|
192
|
+
|
|
171
193
|
private:
|
|
172
194
|
std::chrono::microseconds timeout_{0};
|
|
173
195
|
std::chrono::nanoseconds start_time_{0};
|
|
@@ -176,6 +198,7 @@ struct lcb_CMDSEARCH_ {
|
|
|
176
198
|
void *cookie_{nullptr};
|
|
177
199
|
lcb_SEARCH_CALLBACK callback_{nullptr};
|
|
178
200
|
lcb_SEARCH_HANDLE **handle_{nullptr};
|
|
201
|
+
std::string impostor_{};
|
|
179
202
|
};
|
|
180
203
|
|
|
181
204
|
#endif // LIBCOUCHBASE_CAPI_SEARCH_HH
|
|
@@ -35,6 +35,16 @@ enum class durability_mode {
|
|
|
35
35
|
* @private
|
|
36
36
|
*/
|
|
37
37
|
struct lcb_CMDSTORE_ {
|
|
38
|
+
const std::string &operation_name() const
|
|
39
|
+
{
|
|
40
|
+
static std::map<int, std::string> names{
|
|
41
|
+
{LCB_STORE_UPSERT, LCBTRACE_OP_UPSERT}, {LCB_STORE_REPLACE, LCBTRACE_OP_REPLACE},
|
|
42
|
+
{LCB_STORE_APPEND, LCBTRACE_OP_APPEND}, {LCB_STORE_PREPEND, LCBTRACE_OP_PREPEND},
|
|
43
|
+
{LCB_STORE_INSERT, LCBTRACE_OP_INSERT},
|
|
44
|
+
};
|
|
45
|
+
return names[operation_];
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
lcb_STATUS operation(lcb_STORE_OPERATION operation)
|
|
39
49
|
{
|
|
40
50
|
operation_ = operation;
|
|
@@ -123,24 +133,6 @@ struct lcb_CMDSTORE_ {
|
|
|
123
133
|
return false;
|
|
124
134
|
}
|
|
125
135
|
|
|
126
|
-
const char *operation_name() const
|
|
127
|
-
{
|
|
128
|
-
switch (operation_) {
|
|
129
|
-
case LCB_STORE_UPSERT:
|
|
130
|
-
return LCBTRACE_OP_UPSERT;
|
|
131
|
-
case LCB_STORE_REPLACE:
|
|
132
|
-
return LCBTRACE_OP_REPLACE;
|
|
133
|
-
case LCB_STORE_APPEND:
|
|
134
|
-
return LCBTRACE_OP_APPEND;
|
|
135
|
-
case LCB_STORE_PREPEND:
|
|
136
|
-
return LCBTRACE_OP_PREPEND;
|
|
137
|
-
case LCB_STORE_INSERT:
|
|
138
|
-
return LCBTRACE_OP_INSERT;
|
|
139
|
-
}
|
|
140
|
-
lcb_assert(false && "unknown operation name");
|
|
141
|
-
return "unknown";
|
|
142
|
-
}
|
|
143
|
-
|
|
144
136
|
lcb_STATUS flags(std::uint32_t flags)
|
|
145
137
|
{
|
|
146
138
|
if (operation_ == LCB_STORE_APPEND || operation_ == LCB_STORE_PREPEND) {
|
|
@@ -245,13 +237,16 @@ struct lcb_CMDSTORE_ {
|
|
|
245
237
|
|
|
246
238
|
lcb_STATUS value(const lcb_IOV *iov, std::size_t iov_len)
|
|
247
239
|
{
|
|
248
|
-
std::
|
|
240
|
+
std::size_t total_size = 0;
|
|
241
|
+
for (std::size_t i = 0; i < iov_len; ++i) {
|
|
242
|
+
total_size += iov[i].iov_len;
|
|
243
|
+
}
|
|
244
|
+
value_.reserve(total_size);
|
|
249
245
|
for (std::size_t i = 0; i < iov_len; ++i) {
|
|
250
246
|
if (iov[i].iov_len > 0 && iov[i].iov_base != nullptr) {
|
|
251
|
-
|
|
247
|
+
value_.append(static_cast<const char *>(iov[i].iov_base), iov[i].iov_len);
|
|
252
248
|
}
|
|
253
249
|
}
|
|
254
|
-
value_ = ss.str();
|
|
255
250
|
return LCB_SUCCESS;
|
|
256
251
|
}
|
|
257
252
|
|
|
@@ -370,6 +365,22 @@ struct lcb_CMDSTORE_ {
|
|
|
370
365
|
return preserve_expiry_;
|
|
371
366
|
}
|
|
372
367
|
|
|
368
|
+
lcb_STATUS on_behalf_of(std::string user)
|
|
369
|
+
{
|
|
370
|
+
impostor_ = std::move(user);
|
|
371
|
+
return LCB_SUCCESS;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
bool want_impersonation() const
|
|
375
|
+
{
|
|
376
|
+
return !impostor_.empty();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const std::string &impostor() const
|
|
380
|
+
{
|
|
381
|
+
return impostor_;
|
|
382
|
+
}
|
|
383
|
+
|
|
373
384
|
private:
|
|
374
385
|
lcb::collection_qualifier collection_{};
|
|
375
386
|
std::chrono::microseconds timeout_{0};
|
|
@@ -390,6 +401,7 @@ struct lcb_CMDSTORE_ {
|
|
|
390
401
|
bool compressed_{false};
|
|
391
402
|
bool cookie_is_callback_{false};
|
|
392
403
|
bool preserve_expiry_{false};
|
|
404
|
+
std::string impostor_{};
|
|
393
405
|
};
|
|
394
406
|
|
|
395
407
|
/**
|