libcouchbase 1.0.4 → 1.1.0

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +11 -8
  3. data/ext/libcouchbase/CMakeLists.txt +1 -1
  4. data/ext/libcouchbase/README.markdown +38 -6
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +151 -0
  6. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -2
  7. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  8. data/ext/libcouchbase/cmake/source_files.cmake +1 -0
  9. data/ext/libcouchbase/contrib/cJSON/cJSON.c +686 -288
  10. data/ext/libcouchbase/contrib/cJSON/cJSON.h +0 -0
  11. data/ext/libcouchbase/contrib/cbsasl/src/hash.c +17 -17
  12. data/ext/libcouchbase/contrib/cliopts/cliopts.c +76 -0
  13. data/ext/libcouchbase/contrib/cliopts/cliopts.h +66 -15
  14. data/ext/libcouchbase/contrib/genhash/genhash.c +1 -2
  15. data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4 -3
  16. data/ext/libcouchbase/example/instancepool/main.cc +12 -2
  17. data/ext/libcouchbase/example/libeventdirect/main.c +99 -25
  18. data/ext/libcouchbase/example/minimal/minimal.c +7 -5
  19. data/ext/libcouchbase/example/observe/durability.c +102 -0
  20. data/ext/libcouchbase/example/observe/observe.c +19 -6
  21. data/ext/libcouchbase/example/subdoc/subdoc-xattrs.c +1 -2
  22. data/ext/libcouchbase/include/libcouchbase/cntl-private.h +6 -8
  23. data/ext/libcouchbase/include/libcouchbase/cntl.h +84 -64
  24. data/ext/libcouchbase/include/libcouchbase/couchbase.h +295 -78
  25. data/ext/libcouchbase/include/libcouchbase/deprecated.h +2 -2
  26. data/ext/libcouchbase/include/libcouchbase/error.h +1 -1
  27. data/ext/libcouchbase/include/libcouchbase/iops.h +9 -9
  28. data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +2 -2
  29. data/ext/libcouchbase/include/libcouchbase/n1ql.h +69 -7
  30. data/ext/libcouchbase/include/libcouchbase/vbucket.h +17 -0
  31. data/ext/libcouchbase/include/libcouchbase/views.h +3 -3
  32. data/ext/libcouchbase/include/memcached/protocol_binary.h +62 -1
  33. data/ext/libcouchbase/packaging/deb/control +1 -1
  34. data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +37 -36
  35. data/ext/libcouchbase/src/bootstrap.cc +22 -8
  36. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +1 -1
  37. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +0 -1
  38. data/ext/libcouchbase/src/bucketconfig/confmon.cc +13 -8
  39. data/ext/libcouchbase/src/callbacks.c +2 -0
  40. data/ext/libcouchbase/src/cntl.cc +28 -17
  41. data/ext/libcouchbase/src/dns-srv.cc +1 -2
  42. data/ext/libcouchbase/src/dump.cc +4 -0
  43. data/ext/libcouchbase/src/errmap.h +89 -16
  44. data/ext/libcouchbase/src/handler.cc +28 -11
  45. data/ext/libcouchbase/src/http/http-priv.h +4 -1
  46. data/ext/libcouchbase/src/http/http.cc +3 -0
  47. data/ext/libcouchbase/src/instance.cc +1 -1
  48. data/ext/libcouchbase/src/internal.h +1 -0
  49. data/ext/libcouchbase/src/lcbio/connect.cc +2 -3
  50. data/ext/libcouchbase/src/lcbio/manager.cc +2 -2
  51. data/ext/libcouchbase/src/lcbio/ssl.h +10 -0
  52. data/ext/libcouchbase/src/mc/mcreq.c +8 -0
  53. data/ext/libcouchbase/src/mcserver/mcserver.cc +14 -1
  54. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +0 -3
  55. data/ext/libcouchbase/src/n1ql/n1ql.cc +22 -29
  56. data/ext/libcouchbase/src/n1ql/params.cc +46 -1
  57. data/ext/libcouchbase/src/newconfig.cc +4 -4
  58. data/ext/libcouchbase/src/operations/durability-seqno.cc +4 -0
  59. data/ext/libcouchbase/src/operations/durability.cc +3 -0
  60. data/ext/libcouchbase/src/operations/ping.cc +315 -0
  61. data/ext/libcouchbase/src/operations/stats.cc +10 -0
  62. data/ext/libcouchbase/src/operations/subdoc.cc +13 -1
  63. data/ext/libcouchbase/src/retrychk.cc +1 -0
  64. data/ext/libcouchbase/src/settings.c +2 -0
  65. data/ext/libcouchbase/src/settings.h +13 -7
  66. data/ext/libcouchbase/src/ssl/ssl_c.c +28 -2
  67. data/ext/libcouchbase/src/ssl/ssl_common.c +3 -0
  68. data/ext/libcouchbase/src/ssl/ssl_e.c +15 -1
  69. data/ext/libcouchbase/src/ssl/ssl_iot_common.h +3 -1
  70. data/ext/libcouchbase/src/timings.c +0 -1
  71. data/ext/libcouchbase/src/vbucket/vbucket.c +49 -1
  72. data/ext/libcouchbase/tests/iotests/mock-environment.cc +58 -40
  73. data/ext/libcouchbase/tests/iotests/mock-environment.h +23 -4
  74. data/ext/libcouchbase/tests/iotests/mock-unit-test.h +8 -8
  75. data/ext/libcouchbase/tests/iotests/t_behavior.cc +5 -5
  76. data/ext/libcouchbase/tests/iotests/t_durability.cc +50 -0
  77. data/ext/libcouchbase/tests/iotests/t_eerrs.cc +4 -2
  78. data/ext/libcouchbase/tests/iotests/t_errmap.cc +6 -3
  79. data/ext/libcouchbase/tests/iotests/t_lock.cc +5 -6
  80. data/ext/libcouchbase/tests/iotests/t_misc.cc +44 -0
  81. data/ext/libcouchbase/tests/iotests/t_serverops.cc +1 -0
  82. data/ext/libcouchbase/tests/iotests/t_subdoc.cc +28 -0
  83. data/ext/libcouchbase/tests/iotests/t_views.cc +22 -10
  84. data/ext/libcouchbase/tools/CMakeLists.txt +21 -1
  85. data/ext/libcouchbase/tools/cbc-handlers.h +23 -3
  86. data/ext/libcouchbase/tools/cbc-n1qlback.cc +1 -1
  87. data/ext/libcouchbase/tools/cbc-pillowfight.cc +126 -26
  88. data/ext/libcouchbase/tools/cbc-proxy.cc +403 -0
  89. data/ext/libcouchbase/tools/cbc-subdoc.cc +826 -0
  90. data/ext/libcouchbase/tools/cbc.cc +149 -37
  91. data/ext/libcouchbase/tools/common/options.h +5 -2
  92. data/ext/libcouchbase/tools/linenoise/linenoise.c +15 -15
  93. data/lib/libcouchbase.rb +4 -0
  94. data/lib/libcouchbase/bucket.rb +51 -0
  95. data/lib/libcouchbase/connection.rb +100 -13
  96. data/lib/libcouchbase/ext/libcouchbase.rb +40 -0
  97. data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +13 -1
  98. data/lib/libcouchbase/ext/libcouchbase/enums.rb +2 -1
  99. data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +5 -0
  100. data/lib/libcouchbase/subdoc_request.rb +129 -0
  101. data/lib/libcouchbase/version.rb +1 -1
  102. data/spec/bucket_spec.rb +15 -1
  103. data/spec/connection_spec.rb +1 -1
  104. data/spec/subdoc_spec.rb +192 -0
  105. metadata +13 -4
  106. data/ext/libcouchbase/.travis.yml +0 -19
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2010-2012 Couchbase, Inc.
3
+ * Copyright 2010-2017 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ struct lcb_st;
33
33
 
34
34
  /**
35
35
  * @ingroup lcb-init
36
- * Library handle representing a connection to a data bucket. The contents
36
+ * Library handle representing a connection to a cluster and its data buckets. The contents
37
37
  * of this structure are opaque.
38
38
  * @see lcb_create
39
39
  * @see lcb_destroy
@@ -154,7 +154,7 @@ typedef lcb_U32 lcb_USECS;
154
154
  *
155
155
  * ### Options
156
156
  *
157
- * @warning The key-value options here are considered to be a volatile interface
157
+ * @warning The key-value options here are considered to be an uncommitted interface
158
158
  * as their names may change.
159
159
  *
160
160
  * Options can be specified as the _query_ part of the connection string,
@@ -235,6 +235,19 @@ typedef enum {
235
235
  LCB_TYPE_CLUSTER = 0x01 /**< Handle for administrative access */
236
236
  } lcb_type_t;
237
237
 
238
+ /**
239
+ * @brief Type of the bucket
240
+ *
241
+ * @see https://developer.couchbase.com/documentation/server/current/architecture/core-data-access-buckets.html
242
+ */
243
+ typedef enum {
244
+ LCB_BTYPE_UNSPEC = 0x00, /**< Unknown or unspecified */
245
+ LCB_BTYPE_COUCHBASE = 0x01, /**< Data persisted and replicated */
246
+ LCB_BTYPE_EPHEMERAL = 0x02, /**< Data not persisted, but replicated */
247
+ LCB_BTYPE_MEMCACHED = 0x03 /**< Data not persisted and not replicated */
248
+ } lcb_BTYPE;
249
+
250
+
238
251
  #ifndef __LCB_DOXYGEN__
239
252
  /* These are definitions for some of the older fields of the `lcb_create_st`
240
253
  * structure. They are here for backwards compatibility and should not be
@@ -270,8 +283,10 @@ struct lcb_create_st3 {
270
283
  lcb_type_t type;
271
284
  };
272
285
 
273
- /**@brief Wrapper structure for lcb_create()
274
- * @see lcb_create_st3 */
286
+ /**
287
+ * @brief Wrapper structure for lcb_create()
288
+ * @see lcb_create_st3
289
+ */
275
290
  struct lcb_create_st {
276
291
  /** Indicates which field in the @ref lcb_CRST_u union should be used. Set this to `3` */
277
292
  int version;
@@ -483,10 +498,11 @@ typedef struct lcb_CMDBASE {
483
498
  } lcb_CMDBASE;
484
499
 
485
500
  /**
486
- * @private
487
501
  * Flag for lcb_CMDBASE::cmdflags which indicates that the lcb_CMDBASE::cookie
488
502
  * is a special callback object. This flag is used internally within the
489
503
  * library.
504
+ *
505
+ * @internal
490
506
  */
491
507
  #define LCB_CMD_F_INTERNAL_CALLBACK (1 << 0)
492
508
 
@@ -498,8 +514,6 @@ typedef struct lcb_CMDBASE {
498
514
  #define LCB_CMD_F_MULTIAUTH (1<<1)
499
515
 
500
516
  /**
501
- * @committed
502
- *
503
517
  * Set the key for the command.
504
518
  * @param cmd A command derived from lcb_CMDBASE
505
519
  * @param keybuf the buffer for the key
@@ -517,8 +531,6 @@ typedef struct lcb_CMDBASE {
517
531
  LCB_KREQ_SIMPLE(&(cmd)->key, keybuf, keylen)
518
532
 
519
533
  /**
520
- * @volatile
521
- *
522
534
  * Sets the vBucket ID for the item. This accomplishes the same effect as
523
535
  * _hashkey_ except that this assumes the vBucket has already been obtained.
524
536
  *
@@ -526,6 +538,7 @@ typedef struct lcb_CMDBASE {
526
538
  *
527
539
  * @param cmd the command structure
528
540
  * @param vbid the vBucket ID for the key.
541
+ * @volatile
529
542
  */
530
543
  #define LCB_CMD__SETVBID(cmd, vbid) do { \
531
544
  (cmd)->_hashkey.type = LCB_KV_VBID; \
@@ -577,7 +590,8 @@ typedef struct lcb_CMDBASE {
577
590
  lcb_CAS cas; /**< CAS for response (if applicable) */ \
578
591
  lcb_error_t rc; /**< Status code */ \
579
592
  lcb_U16 version; /**< ABI version for response */ \
580
- lcb_U16 rflags; /**< Response specific flags. see ::lcb_RESPFLAGS */
593
+ /** Response specific flags. see ::lcb_RESPFLAGS */ \
594
+ lcb_U16 rflags;
581
595
 
582
596
 
583
597
  /**
@@ -594,7 +608,8 @@ typedef struct {
594
608
  /** String containing the `host:port` of the server which sent this response */ \
595
609
  const char *server;
596
610
 
597
- /**@brief Base structure for informational commands from servers
611
+ /**
612
+ * @brief Base structure for informational commands from servers
598
613
  * This contains an additional lcb_RESPSERVERBASE::server field containing the
599
614
  * server which emitted this response.
600
615
  */
@@ -675,6 +690,8 @@ typedef enum {
675
690
  LCB_CALLBACK_STOREDUR, /** <for lcb_storedur3() */
676
691
  LCB_CALLBACK_SDLOOKUP,
677
692
  LCB_CALLBACK_SDMUTATE,
693
+ LCB_CALLBACK_NOOP, /**< lcb_noop3() */
694
+ LCB_CALLBACK_PING, /**< lcb_ping3() */
678
695
  LCB_CALLBACK__MAX /* Number of callbacks */
679
696
  } lcb_CALLBACKTYPE;
680
697
 
@@ -689,11 +706,10 @@ typedef enum {
689
706
  /** Callback type for N1QL (cannot be used for lcb_install_callback3()) */
690
707
  #define LCB_CALLBACK_N1QL -2
691
708
 
709
+ /** Callback type for N1QL index management (cannot be used for lcb_install_callback3()) */
692
710
  #define LCB_CALLBACK_IXMGMT -3
693
711
 
694
712
  /**
695
- * @committed
696
- *
697
713
  * Callback invoked for responses.
698
714
  * @param instance The handle
699
715
  * @param cbtype The type of callback - or in other words, the type of operation
@@ -746,8 +762,6 @@ lcb_RESPCALLBACK
746
762
  lcb_get_callback3(lcb_t instance, int cbtype);
747
763
 
748
764
  /**
749
- * @committed
750
- *
751
765
  * Returns the type of the callback as a string.
752
766
  * This function is helpful for debugging and demonstrative processes.
753
767
  * @param cbtype the type of the callback (the second argument to the callback)
@@ -814,7 +828,7 @@ typedef struct {
814
828
  const void *value; /**< Value buffer for the item */
815
829
  lcb_SIZE nvalue; /**< Length of value */
816
830
  void* bufh;
817
- lcb_datatype_t datatype; /**< @private */
831
+ lcb_datatype_t datatype; /**< @internal */
818
832
  lcb_U32 itmflags; /**< User-defined flags for the item */
819
833
  } lcb_RESPGET;
820
834
 
@@ -1152,7 +1166,7 @@ typedef struct {
1152
1166
  * if (rb->rc == LCB_SUCCESS) {
1153
1167
  * printf("Store success: CAS=%llx\n", rb->cas);
1154
1168
  * } else {
1155
- * printf("Store failed: %s\n", lcb_strerorr(NULL, rb->rc);
1169
+ * printf("Store failed: %s\n", lcb_strerror(NULL, rb->rc);
1156
1170
  * }
1157
1171
  * }
1158
1172
  * @endcode
@@ -1449,7 +1463,7 @@ typedef struct lcb_durability_opts_st {
1449
1463
 
1450
1464
  /**Must specify this flag if using the 'mutation_token' field, as it was added in
1451
1465
  * a later version */
1452
- #define LCB_CMDENDURE_F_MUTATION_TOKEN 1<<16
1466
+ #define LCB_CMDENDURE_F_MUTATION_TOKEN (1 << 16)
1453
1467
 
1454
1468
  /**@brief Command structure for endure.
1455
1469
  * If the lcb_CMDENDURE::cas field is specified, the operation will check and
@@ -1630,7 +1644,7 @@ typedef struct {
1630
1644
  LCB_CMD_BASE;
1631
1645
  lcb_VALBUF value; /**< @see lcb_CMDSTORE::value */
1632
1646
  lcb_U32 flags; /**< @see lcb_CMDSTORE::flags */
1633
- lcb_datatype_t datatype; /**< @private */
1647
+ lcb_datatype_t datatype; /**< @internal */
1634
1648
  lcb_storage_t operation; /**< @see lcb_CMDSTORE::operation */
1635
1649
 
1636
1650
  /**
@@ -1675,7 +1689,7 @@ LIBCOUCHBASE_API
1675
1689
  lcb_error_t
1676
1690
  lcb_storedur3(lcb_t instance, const void *cookie, const lcb_CMDSTOREDUR *cmd);
1677
1691
 
1678
- #define LCB_DURABILITY_VALIDATE_CAPMAX 1<<1
1692
+ #define LCB_DURABILITY_VALIDATE_CAPMAX (1 << 1)
1679
1693
 
1680
1694
  /**
1681
1695
  * @committed
@@ -1718,7 +1732,7 @@ lcb_durability_validate(lcb_t instance,
1718
1732
 
1719
1733
  /**Set this bit in the cmdflags field to indicate that only the master node
1720
1734
  * should be contacted*/
1721
- #define LCB_CMDOBSERVE_F_MASTER_ONLY 1<<16
1735
+ #define LCB_CMDOBSERVE_F_MASTER_ONLY (1 << 16)
1722
1736
 
1723
1737
  /**@brief Structure for an observe request.
1724
1738
  * To request the status from _only_ the master node of the key, set the
@@ -1761,10 +1775,11 @@ typedef struct {
1761
1775
  lcb_U32 ttr; /**<Unused */
1762
1776
  } lcb_RESPOBSERVE;
1763
1777
 
1764
- /**@committed
1778
+ /**
1765
1779
  * @brief Create a new multi context for an observe operation
1766
1780
  * @param instance the instance
1767
1781
  * @return a new multi command context, or NULL on allocation failure.
1782
+ * @committed
1768
1783
  *
1769
1784
  * Note that the callback for this command will be invoked multiple times,
1770
1785
  * one for each node. To determine when no more callbacks will be invoked,
@@ -1877,11 +1892,11 @@ lcb_observe_seqno3(lcb_t instance, const void *cookie, const lcb_CMDOBSEQNO *cmd
1877
1892
  */
1878
1893
 
1879
1894
  /** Get the vBucket UUID */
1880
- #define LCB_MUTATION_TOKEN_ID(p) (p)->uuid_
1895
+ #define LCB_MUTATION_TOKEN_ID(p) ((p)->uuid_)
1881
1896
  /** Get the sequence number */
1882
- #define LCB_MUTATION_TOKEN_SEQ(p) (p)->seqno_
1897
+ #define LCB_MUTATION_TOKEN_SEQ(p) ((p)->seqno_)
1883
1898
  /** Get the vBucket number itself */
1884
- #define LCB_MUTATION_TOKEN_VB(p) (p)->vbid_
1899
+ #define LCB_MUTATION_TOKEN_VB(p) ((p)->vbid_)
1885
1900
  /** Whether this mutation token has valid contents */
1886
1901
  #define LCB_MUTATION_TOKEN_ISVALID(p) \
1887
1902
  (p && !((p)->uuid_ == 0 && (p)->seqno_ == 0 && (p)->vbid_ == 0))
@@ -1954,7 +1969,8 @@ lcb_get_mutation_token(lcb_t instance, const lcb_KEYBUF *kb, lcb_error_t *errp);
1954
1969
 
1955
1970
  /**@} (Group: Mutation Tokens) */
1956
1971
 
1957
- /**@ingroup lcb-kv-api
1972
+ /**
1973
+ * @ingroup lcb-kv-api
1958
1974
  * @defgroup lcb-counter Counters
1959
1975
  * @brief Manipulate the numeric content of a document
1960
1976
  * @details Counter operations treat the document being accessed as a numeric
@@ -1965,7 +1981,8 @@ lcb_get_mutation_token(lcb_t instance, const lcb_KEYBUF *kb, lcb_error_t *errp);
1965
1981
  * @{
1966
1982
  */
1967
1983
 
1968
- /**@brief Command for counter operations.
1984
+ /**
1985
+ * @brief Command for counter operations.
1969
1986
  * @see lcb_counter3(), lcb_RESPCOUNTER.
1970
1987
  *
1971
1988
  * @warning You may only set the #exptime member if the #create member is set
@@ -1989,7 +2006,8 @@ typedef struct {
1989
2006
  int create;
1990
2007
  } lcb_CMDCOUNTER;
1991
2008
 
1992
- /**@brief Response structure for counter operations
2009
+ /**
2010
+ * @brief Response structure for counter operations
1993
2011
  * @see lcb_counter3()
1994
2012
  */
1995
2013
  typedef struct {
@@ -2254,14 +2272,17 @@ typedef struct {
2254
2272
  lcb_SIZE nversion; /**< Length of the version string */
2255
2273
  } lcb_RESPMCVERSION;
2256
2274
 
2257
- /**@volatile*/
2275
+ /**
2276
+ * @volatile
2277
+ */
2258
2278
  LIBCOUCHBASE_API
2259
2279
  lcb_error_t
2260
2280
  lcb_server_versions3(lcb_t instance, const void *cookie, const lcb_CMDBASE * cmd);
2261
2281
 
2262
2282
  /**@} (Name: MCversion) */
2263
2283
 
2264
- /**@name Server Log Verbosity
2284
+ /**
2285
+ * @name Server Log Verbosity
2265
2286
  * @{
2266
2287
  */
2267
2288
 
@@ -2287,7 +2308,8 @@ lcb_server_verbosity3(lcb_t instance, const void *cookie, const lcb_CMDVERBOSITY
2287
2308
  /**@} (Name: Verbosity) */
2288
2309
  /**@} (Group: Misc) */
2289
2310
 
2290
- /**@ingroup lcb-public-api
2311
+ /**
2312
+ * @ingroup lcb-public-api
2291
2313
  * @defgroup lcb-flush Flush
2292
2314
  * @brief Clear the contents of a bucket
2293
2315
  *
@@ -2338,6 +2360,180 @@ lcb_error_t
2338
2360
  lcb_flush3(lcb_t instance, const void *cookie, const lcb_CMDFLUSH *cmd);
2339
2361
  /**@} (Group: Flush) */
2340
2362
 
2363
+ /**
2364
+ * @ingroup lcb-public-api
2365
+ * @defgroup lcb-noop NOOP
2366
+ * @brief Send NOOP command to server
2367
+ *
2368
+ * @addtogroup lcb-noop
2369
+ * @{
2370
+ */
2371
+ typedef lcb_CMDBASE lcb_CMDNOOP;
2372
+ typedef lcb_RESPSERVERBASE lcb_RESPNOOP;
2373
+
2374
+ /**
2375
+ * @uncommitted
2376
+ *
2377
+ * Send NOOP to the node
2378
+ *
2379
+ * @param instance the library handle
2380
+ * @param cookie the cookie passed in the callback
2381
+ * @param cmd empty command structure.
2382
+ * @return status code for scheduling.
2383
+ */
2384
+ LIBCOUCHBASE_API
2385
+ lcb_error_t
2386
+ lcb_noop3(lcb_t instance, const void *cookie, const lcb_CMDNOOP *cmd);
2387
+ /**@} (Group: NOOP) */
2388
+
2389
+ /**
2390
+ * @ingroup lcb-public-api
2391
+ * @defgroup lcb-ping PING
2392
+ * @brief Broadcast NOOP-like commands to each service in the cluster
2393
+ *
2394
+ * @addtogroup lcb-ping
2395
+ * @{
2396
+ */
2397
+
2398
+ /**
2399
+ * Ping data (Key/Value) service. Used in lcb_CMDPING#services
2400
+ */
2401
+ #define LCB_PINGSVC_F_KV 0x01
2402
+
2403
+ /**
2404
+ * Ping query (N1QL) service. Used in lcb_CMDPING#services
2405
+ */
2406
+ #define LCB_PINGSVC_F_N1QL 0x02
2407
+
2408
+ /**
2409
+ * Ping views (Map/Reduce) service. Used in lcb_CMDPING#services
2410
+ */
2411
+ #define LCB_PINGSVC_F_VIEWS 0x04
2412
+
2413
+ /**
2414
+ * Ping full text search (FTS) service. Used in lcb_CMDPING#services
2415
+ */
2416
+ #define LCB_PINGSVC_F_FTS 0x08
2417
+
2418
+ /**
2419
+ * Do not record any metrics or status codes from ping responses.
2420
+ * This might be useful to reduce overhead, when user-space
2421
+ * keep-alive mechanism is not interested in actual latencies,
2422
+ * but rather need keep sockets active. Used in lcb_CMDPING#options
2423
+ */
2424
+ #define LCB_PINGOPT_F_NOMETRICS 0x01
2425
+
2426
+ /**
2427
+ * Automatically encode PING result as JSON. See njson/json fields
2428
+ * of #lcb_RESPPING structure. Used in lcb_CMDPING#options
2429
+ */
2430
+ #define LCB_PINGOPT_F_JSON 0x02
2431
+
2432
+ /**
2433
+ * Add extra details about service status into generated JSON.
2434
+ * Requires LCB_PINGOPT_F_JSON to be set. Used in lcb_CMDPING#options
2435
+ */
2436
+ #define LCB_PINGOPT_F_JSONDETAILS 0x04
2437
+
2438
+ /**
2439
+ * Generate indented JSON, which is better for reading. Used in lcb_CMDPING#options
2440
+ */
2441
+ #define LCB_PINGOPT_F_JSONPRETTY 0x08
2442
+
2443
+ /**
2444
+ * Structure for PING requests.
2445
+ *
2446
+ * @uncommitted
2447
+ */
2448
+ typedef struct {
2449
+ LCB_CMD_BASE;
2450
+ int services; /**< bitmap for services to ping */
2451
+ int options; /**< extra options, e.g. for result representation */
2452
+ } lcb_CMDPING;
2453
+
2454
+ /**
2455
+ * Type of the service. This enumeration is used in PING responses.
2456
+ *
2457
+ * @uncommitted
2458
+ */
2459
+ typedef enum {
2460
+ LCB_PINGSVC_KV = 0,
2461
+ LCB_PINGSVC_VIEWS,
2462
+ LCB_PINGSVC_N1QL,
2463
+ LCB_PINGSVC_FTS,
2464
+ LCB_PINGSVC__MAX
2465
+ } lcb_PINGSVCTYPE;
2466
+
2467
+ /**
2468
+ * Entry describing the status of the service in the cluster.
2469
+ * It is part of lcb_RESPING structure.
2470
+ *
2471
+ * @uncommitted
2472
+ */
2473
+ typedef struct {
2474
+ lcb_PINGSVCTYPE type; /**< type of the service */
2475
+ char *server; /**< server host:port */
2476
+ lcb_U64 latency; /**< latency in nanoseconds */
2477
+ lcb_error_t status; /**< status of the operation */
2478
+ } lcb_PINGSVC;
2479
+
2480
+ /**
2481
+ * Structure for PING responses.
2482
+ *
2483
+ * @uncommitted
2484
+ */
2485
+ typedef struct {
2486
+ LCB_RESP_BASE
2487
+ LCB_RESP_SERVER_FIELDS
2488
+ lcb_SIZE nservices; /**< number of the nodes, replied to ping */
2489
+ lcb_PINGSVC *services; /**< the nodes, replied to ping, if any */
2490
+ lcb_SIZE njson; /**< length of JSON string (when #LCB_PINGOPT_F_JSON was specified) */
2491
+ const char *json; /**< pointer to JSON string */
2492
+ } lcb_RESPPING;
2493
+
2494
+ /**
2495
+ * @brief Check connections by sending NOOP-like messages to all services.
2496
+ *
2497
+ * @uncommitted
2498
+ *
2499
+ * When no metrics, required, it is possible to reduce memory overhead
2500
+ * by turning off response contents using #LCB_PINGOPT_F_NOMETRICS.
2501
+ *
2502
+ * @par Request
2503
+ * @code{.c}
2504
+ * lcb_CMDPING cmd = { 0 };
2505
+ * // select services to ping
2506
+ * cmd.services = LCB_PINGSVC_F_KV | LCB_PINGSVC_F_N1QL;
2507
+ * lcb_ping3(instance, fp, &cmd);
2508
+ * lcb_wait(instance);
2509
+ * @endcode
2510
+ *
2511
+ * @par Response
2512
+ * @code{.c}
2513
+ * lcb_install_callback3(instance, LCB_CALLBACK_PING, ping_callback);
2514
+ * void ping_callback(lcb_t, int, const lcb_RESPBASE *rb)
2515
+ * {
2516
+ * const lcb_RESPPING *resp = (const lcb_RESPPING*)rb;
2517
+ * int ii;
2518
+ * for (ii = 0; ii < resp->nservices; ii++) {
2519
+ * printf("service: %s, status: %d, host: %s, latency: %lu nanoseconds\n",
2520
+ * resp->services[ii].type == LCB_PINGSVC_KV ? "KV" : "N1QL",
2521
+ * resp->services[ii].status,
2522
+ * resp->services[ii].server,
2523
+ * (unsigned long)resp->services[ii].latency);
2524
+ * }
2525
+ * }
2526
+ * @endcode
2527
+ * @param instance the library handle
2528
+ * @param cookie the cookie passed in the callback
2529
+ * @param cmd empty command structure.
2530
+ * @return status code for scheduling.
2531
+ */
2532
+ LIBCOUCHBASE_API
2533
+ lcb_error_t
2534
+ lcb_ping3(lcb_t instance, const void *cookie, const lcb_CMDPING *cmd);
2535
+ /**@} (Group: PING) */
2536
+
2341
2537
  /**@ingroup lcb-public-api
2342
2538
  * @defgroup lcb-http HTTP Client
2343
2539
  * @brief Access Couchbase HTTP APIs
@@ -2380,6 +2576,9 @@ typedef enum {
2380
2576
  /** Search a fulltext index */
2381
2577
  LCB_HTTP_TYPE_FTS = 4,
2382
2578
 
2579
+ /** Execute an Analytics Query */
2580
+ LCB_HTTP_TYPE_CBAS = 5,
2581
+
2383
2582
  LCB_HTTP_TYPE_MAX
2384
2583
  } lcb_http_type_t;
2385
2584
 
@@ -2406,20 +2605,20 @@ typedef enum {
2406
2605
  * To use streaming requests, this flag should be set in the
2407
2606
  * lcb_CMDHTTP::cmdflags field
2408
2607
  */
2409
- #define LCB_CMDHTTP_F_STREAM 1<<16
2608
+ #define LCB_CMDHTTP_F_STREAM (1 << 16)
2410
2609
 
2411
2610
  /**
2412
- * @private
2611
+ * @internal
2413
2612
  * If specified, the lcb_CMDHTTP::cas field becomes the timeout for this
2414
2613
  * specific request.
2415
2614
  */
2416
- #define LCB_CMDHTTP_F_CASTMO 1<<17
2615
+ #define LCB_CMDHTTP_F_CASTMO (1 << 17)
2417
2616
 
2418
2617
  /**
2419
- * @private
2618
+ * @internal
2420
2619
  * Do not inject authentication header into the request.
2421
2620
  */
2422
- #define LCB_CMDHTTP_F_NOUPASS 1<<18
2621
+ #define LCB_CMDHTTP_F_NOUPASS (1 << 18)
2423
2622
 
2424
2623
  /**
2425
2624
  * Structure for performing an HTTP request.
@@ -2485,7 +2684,7 @@ typedef struct {
2485
2684
  const void *body;
2486
2685
  /** Length of buffer in #body */
2487
2686
  lcb_SIZE nbody;
2488
- /**@private*/
2687
+ /**@internal*/
2489
2688
  lcb_http_request_t _htreq;
2490
2689
  } lcb_RESPHTTP;
2491
2690
 
@@ -2575,7 +2774,8 @@ void
2575
2774
  lcb_cancel_http_request(lcb_t instance, lcb_http_request_t request);
2576
2775
  /**@} (Group: HTTP) */
2577
2776
 
2578
- /**@ingroup lcb-public-api
2777
+ /**
2778
+ * @ingroup lcb-public-api
2579
2779
  * @defgroup lcb-cookie User Cookies
2580
2780
  * @brief Associate user-defined data with operations
2581
2781
  * @details
@@ -3036,10 +3236,10 @@ void lcb_destroy_async(lcb_t instance, const void *arg);
3036
3236
 
3037
3237
  /**@}*/
3038
3238
 
3039
- /** @private */
3239
+ /** @internal */
3040
3240
  #define LCB_DATATYPE_JSON 0x01
3041
3241
 
3042
- /** @private */
3242
+ /** @internal */
3043
3243
  typedef enum { LCB_VALUE_RAW = 0x00, LCB_VALUE_F_JSON = 0x01, LCB_VALUE_F_SNAPPYCOMP } lcb_VALUEFLAGS;
3044
3244
 
3045
3245
 
@@ -3277,8 +3477,9 @@ lcb_dump(lcb_t instance, FILE *fp, lcb_U32 flags);
3277
3477
  LIBCOUCHBASE_API
3278
3478
  lcb_error_t lcb_cntl(lcb_t instance, int mode, int cmd, void *arg);
3279
3479
 
3480
+
3280
3481
  /**
3281
- * Alternate way to set configuration settings by passing a string key
3482
+ * Alternatively one may change configuration settings by passing a string key
3282
3483
  * and value. This may be used to provide a simple interface from a command
3283
3484
  * line or higher level language to allow the setting of specific key-value
3284
3485
  * pairs.
@@ -3286,8 +3487,9 @@ lcb_error_t lcb_cntl(lcb_t instance, int mode, int cmd, void *arg);
3286
3487
  * The format for the value is dependent on the option passed, the following
3287
3488
  * value types exist:
3288
3489
  *
3289
- * - **Timeout**. A _timeout_ value can either be specified as fractional
3290
- * seconds (`"1.5"` for 1.5 seconds), or in microseconds (`"1500000"`).
3490
+ * - **Timeval**. A _timeval_ value can either be specified as fractional
3491
+ * seconds (`"1.5"` for 1.5 seconds), or in microseconds (`"1500000"`). In
3492
+ * releases prior to libcouchbase 2.8, this was called _timeout_.
3291
3493
  * - **Number**. This is any valid numerical value. This may be signed or
3292
3494
  * unsigned depending on the setting.
3293
3495
  * - **Boolean**. This specifies a boolean. A true value is either a positive
@@ -3295,26 +3497,41 @@ lcb_error_t lcb_cntl(lcb_t instance, int mode, int cmd, void *arg);
3295
3497
  * is a zero (i.e. `"0"`) or the string `"false"`.
3296
3498
  * - **Float**. This is like a _Number_, but also allows fractional specification,
3297
3499
  * e.g. `"2.4"`.
3298
- *
3299
- * | Code | Name | Type
3300
- * |------|------|-----
3301
- * |@ref LCB_CNTL_OP_TIMEOUT | `"operation_timeout"` | Timeout |
3302
- * |@ref LCB_CNTL_VIEW_TIMEOUT | `"view_timeout"` | Timeout |
3303
- * |@ref LCB_CNTL_DURABILITY_TIMEOUT | `"durability_timeout"` | Timeout |
3304
- * |@ref LCB_CNTL_DURABILITY_INTERVAL | `"durability_interval"`| Timeout |
3305
- * |@ref LCB_CNTL_HTTP_TIMEOUT | `"http_timeout"` | Timeout |
3306
- * |@ref LCB_CNTL_RANDOMIZE_BOOTSTRAP_HOSTS | `"randomize_nodes"` | Boolean|
3307
- * |@ref LCB_CNTL_CONFERRTHRESH | `"error_thresh_count"`| Number (Positive)|
3308
- * |@ref LCB_CNTL_CONFDELAY_THRESH |`"error_thresh_delay"` | Timeout |
3309
- * |@ref LCB_CNTL_CONFIGURATION_TIMEOUT | `"config_total_timeout"`|Timeout|
3310
- * |@ref LCB_CNTL_CONFIG_NODE_TIMEOUT | `"config_node_timeout"` | Timeout |
3311
- * |@ref LCB_CNTL_CONFIGCACHE | `"config_cache"` | Path |
3312
- * |@ref LCB_CNTL_DETAILED_ERRCODES | `"detailed_errcodes"` | Boolean |
3313
- * |@ref LCB_CNTL_HTCONFIG_URLTYPE | `"http_urlmode"` | Number (values are the constant values) |
3314
- * |@ref LCB_CNTL_RETRY_BACKOFF | `"retry_backoff"` | Float |
3315
- * |@ref LCB_CNTL_HTTP_POOLSIZE | `"http_poolsize"` | Number |
3316
- * |@ref LCB_CNTL_VBGUESS_PERSIST | `"vbguess_persist"` | Boolean |
3317
- *
3500
+ * - **String**. Arbitrary string as `char *`, e.g. for client identification
3501
+ * string.
3502
+ * - **Path**. File path.
3503
+ * - **FILE*, Path**. Set file stream pointer (lcb_cntl() style) or file path
3504
+ * (lcb_cntl_string() style).
3505
+ *
3506
+ * | Code | Name | Type |
3507
+ * |-----------------------------------------|---------------------------|-------------------|
3508
+ * |@ref LCB_CNTL_OP_TIMEOUT | `"operation_timeout"` | Timeval |
3509
+ * |@ref LCB_CNTL_VIEW_TIMEOUT | `"view_timeout"` | Timeval |
3510
+ * |@ref LCB_CNTL_N1QL_TIMEOUT | `"n1ql_timeout"` | Timeval |
3511
+ * |@ref LCB_CNTL_HTTP_TIMEOUT | `"http_timeout"` | Timeval |
3512
+ * |@ref LCB_CNTL_CONFIG_POLL_INTERVAL | `"config_poll_interval"` | Timeval |
3513
+ * |@ref LCB_CNTL_CONFERRTHRESH | `"error_thresh_count"` | Number (Positive) |
3514
+ * |@ref LCB_CNTL_CONFIGURATION_TIMEOUT | `"config_total_timeout"` | Timeval |
3515
+ * |@ref LCB_CNTL_CONFIG_NODE_TIMEOUT | `"config_node_timeout"` | Timeval |
3516
+ * |@ref LCB_CNTL_CONFDELAY_THRESH | `"error_thresh_delay"` | Timeval |
3517
+ * |@ref LCB_CNTL_DURABILITY_TIMEOUT | `"durability_timeout"` | Timeval |
3518
+ * |@ref LCB_CNTL_DURABILITY_INTERVAL | `"durability_interval"` | Timeval |
3519
+ * |@ref LCB_CNTL_RANDOMIZE_BOOTSTRAP_HOSTS | `"randomize_nodes"` | Boolean |
3520
+ * |@ref LCB_CNTL_CONFIGCACHE | `"config_cache"` | Path |
3521
+ * |@ref LCB_CNTL_DETAILED_ERRCODES | `"detailed_errcodes"` | Boolean |
3522
+ * |@ref LCB_CNTL_HTCONFIG_URLTYPE | `"http_urlmode"` | Number (enum #lcb_HTCONFIG_URLTYPE) |
3523
+ * |@ref LCB_CNTL_RETRY_BACKOFF | `"retry_backoff"` | Float |
3524
+ * |@ref LCB_CNTL_RETRY_INTERVAL | `"retry_interval"` | Timeval |
3525
+ * |@ref LCB_CNTL_HTTP_POOLSIZE | `"http_poolsize"` | Number |
3526
+ * |@ref LCB_CNTL_VBGUESS_PERSIST | `"vbguess_persist"` | Boolean |
3527
+ * |@ref LCB_CNTL_CONLOGGER_LEVEL | `"console_log_level"` | Number (enum #lcb_log_severity_t) |
3528
+ * |@ref LCB_CNTL_FETCH_MUTATION_TOKENS | `"fetch_mutation_tokens"` | Boolean |
3529
+ * |@ref LCB_CNTL_DURABILITY_MUTATION_TOKENS | `"dur_mutation_tokens"` | Boolean |
3530
+ * |@ref LCB_CNTL_TCP_NODELAY | `"tcp_nodelay"` | Boolean |
3531
+ * |@ref LCB_CNTL_CONLOGGER_FP | `"console_log_file"` | FILE*, Path |
3532
+ * |@ref LCB_CNTL_CLIENT_STRING | `"client_string"` | String |
3533
+ * |@ref LCB_CNTL_TCP_KEEPALIVE | `"tcp_keepalive"` | Boolean |
3534
+ * |@ref LCB_CNTL_CONFIG_POLL_INTERVAL | `"config_poll_interval"` | Timeval |
3318
3535
  *
3319
3536
  * @committed - Note, the actual API call is considered committed and will
3320
3537
  * not disappear, however the existence of the various string settings are
@@ -3601,7 +3818,7 @@ LIBCOUCHBASE_API
3601
3818
  void lcb_mem_free(void *ptr);
3602
3819
 
3603
3820
  /**
3604
- * @private
3821
+ * @internal
3605
3822
  *
3606
3823
  * These two functions unconditionally start and stop the event loop. These
3607
3824
  * should be used _only_ when necessary. Use lcb_wait and lcb_breakout
@@ -3612,11 +3829,11 @@ void lcb_mem_free(void *ptr);
3612
3829
  LCB_INTERNAL_API
3613
3830
  void lcb_run_loop(lcb_t instance);
3614
3831
 
3615
- /** @private */
3832
+ /** @internal */
3616
3833
  LCB_INTERNAL_API
3617
3834
  void lcb_stop_loop(lcb_t instance);
3618
3835
 
3619
- /** @private */
3836
+ /** @internal */
3620
3837
  /* This returns the library's idea of time */
3621
3838
  LCB_INTERNAL_API
3622
3839
  lcb_U64 lcb_nstime(void);
@@ -3632,34 +3849,34 @@ typedef enum {
3632
3849
  LCB_DUMP_ALL = 0xff
3633
3850
  } lcb_DUMPFLAGS;
3634
3851
 
3635
- /** Internal histogram APIs, used by pillowfight and others */
3852
+ /** Volatile histogram APIs, used by pillowfight and others */
3636
3853
  struct lcb_histogram_st;
3637
3854
  typedef struct lcb_histogram_st lcb_HISTOGRAM;
3638
3855
 
3639
3856
  /**
3640
- * @private
3857
+ * @volatile
3641
3858
  * Create a histogram structure
3642
3859
  * @return a new histogram structure
3643
3860
  */
3644
- LCB_INTERNAL_API
3861
+ LIBCOUCHBASE_API
3645
3862
  lcb_HISTOGRAM *
3646
3863
  lcb_histogram_create(void);
3647
3864
 
3648
3865
  /**
3649
- * @private free a histogram structure
3866
+ * @volatile free a histogram structure
3650
3867
  * @param hg the histogram
3651
3868
  */
3652
- LCB_INTERNAL_API
3869
+ LIBCOUCHBASE_API
3653
3870
  void
3654
3871
  lcb_histogram_destroy(lcb_HISTOGRAM *hg);
3655
3872
 
3656
3873
  /**
3657
- * @private
3874
+ * @volatile
3658
3875
  * Add an entry to a histogram structure
3659
3876
  * @param hg the histogram
3660
3877
  * @param duration the duration in nanoseconds
3661
3878
  */
3662
- LCB_INTERNAL_API
3879
+ LIBCOUCHBASE_API
3663
3880
  void
3664
3881
  lcb_histogram_record(lcb_HISTOGRAM *hg, lcb_U64 duration);
3665
3882
 
@@ -3668,13 +3885,13 @@ typedef void (*lcb_HISTOGRAM_CALLBACK)
3668
3885
  lcb_U32 total, lcb_U32 maxtotal);
3669
3886
 
3670
3887
  /**
3671
- * @private
3888
+ * @volatile
3672
3889
  * Repeatedly invoke a callback for all entries in the histogram
3673
3890
  * @param hg the histogram
3674
3891
  * @param cookie pointer passed to callback
3675
3892
  * @param cb callback to invoke
3676
3893
  */
3677
- LCB_INTERNAL_API
3894
+ LIBCOUCHBASE_API
3678
3895
  void
3679
3896
  lcb_histogram_read(const lcb_HISTOGRAM *hg, const void *cookie,
3680
3897
  lcb_HISTOGRAM_CALLBACK cb);
@@ -3689,7 +3906,7 @@ lcb_histogram_read(const lcb_HISTOGRAM *hg, const void *cookie,
3689
3906
  * @param hg the histogram
3690
3907
  * @param stream File to print the histogram to.
3691
3908
  */
3692
- LCB_INTERNAL_API
3909
+ LIBCOUCHBASE_API
3693
3910
  void lcb_histogram_print(lcb_HISTOGRAM* hg, FILE* stream);
3694
3911
 
3695
3912
  /**
@@ -3708,7 +3925,7 @@ const char *
3708
3925
  lcb_resp_get_error_context(int cbtype, const lcb_RESPBASE *rb);
3709
3926
 
3710
3927
  /**
3711
- * @volatile
3928
+ * @uncommitted
3712
3929
  *
3713
3930
  * Retrieves the error reference id from the response structure.
3714
3931
  *