libcouchbase 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (561) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +35 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +24 -0
  8. data/README.md +389 -0
  9. data/Rakefile +75 -0
  10. data/ext/README.md +6 -0
  11. data/ext/Rakefile +20 -0
  12. data/ext/libcouchbase/.gitignore +130 -0
  13. data/ext/libcouchbase/.travis.yml +19 -0
  14. data/ext/libcouchbase/CMakeLists.txt +429 -0
  15. data/ext/libcouchbase/CONTRIBUTING.md +124 -0
  16. data/ext/libcouchbase/LICENSE +202 -0
  17. data/ext/libcouchbase/README.markdown +163 -0
  18. data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
  19. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
  20. data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
  21. data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
  22. data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
  23. data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
  24. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
  25. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
  26. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
  27. data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
  28. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
  29. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
  30. data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
  31. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
  32. data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
  33. data/ext/libcouchbase/cmake/configure +357 -0
  34. data/ext/libcouchbase/cmake/defs.mk.in +8 -0
  35. data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
  36. data/ext/libcouchbase/cmake/source_files.cmake +73 -0
  37. data/ext/libcouchbase/configure.pl +1 -0
  38. data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
  39. data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
  40. data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
  41. data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
  42. data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
  43. data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
  44. data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
  45. data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
  46. data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
  47. data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
  48. data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
  49. data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
  50. data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
  51. data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
  52. data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
  53. data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
  54. data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
  55. data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
  56. data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
  57. data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
  58. data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
  59. data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
  60. data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
  61. data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
  62. data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
  63. data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
  64. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
  65. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
  66. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
  67. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
  68. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
  69. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
  70. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
  71. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
  72. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
  73. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
  74. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
  75. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
  76. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
  77. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
  78. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
  79. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
  80. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
  81. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
  82. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
  83. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
  84. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
  85. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
  86. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
  87. data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
  88. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
  89. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
  90. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
  91. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
  92. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
  93. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
  94. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
  95. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
  96. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
  97. data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
  98. data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
  99. data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
  100. data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
  101. data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
  102. data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
  103. data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
  104. data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
  105. data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
  106. data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
  107. data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
  108. data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
  109. data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
  110. data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
  111. data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
  112. data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
  113. data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
  114. data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
  115. data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
  116. data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
  117. data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
  118. data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
  119. data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
  120. data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
  121. data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
  122. data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
  123. data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
  124. data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
  125. data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
  126. data/ext/libcouchbase/example/CMakeLists.txt +37 -0
  127. data/ext/libcouchbase/example/README.markdown +47 -0
  128. data/ext/libcouchbase/example/db/db.c +167 -0
  129. data/ext/libcouchbase/example/db/vb.c +227 -0
  130. data/ext/libcouchbase/example/instancepool/main.cc +102 -0
  131. data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
  132. data/ext/libcouchbase/example/instancepool/pool.h +69 -0
  133. data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
  134. data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
  135. data/ext/libcouchbase/example/minimal/minimal.c +130 -0
  136. data/ext/libcouchbase/example/observe/observe.c +146 -0
  137. data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
  138. data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
  139. data/ext/libcouchbase/example/tick/tick.c +119 -0
  140. data/ext/libcouchbase/example/views/views-example.cc +83 -0
  141. data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
  142. data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
  143. data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
  144. data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
  145. data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
  146. data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
  147. data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
  148. data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
  149. data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
  150. data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
  151. data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
  152. data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
  153. data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
  154. data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
  155. data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
  156. data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
  157. data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
  158. data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
  159. data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
  160. data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
  161. data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
  162. data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
  163. data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
  164. data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
  165. data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
  166. data/ext/libcouchbase/include/memcached/COPYING +30 -0
  167. data/ext/libcouchbase/include/memcached/README +10 -0
  168. data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
  169. data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
  170. data/ext/libcouchbase/packaging/README +7 -0
  171. data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
  172. data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
  173. data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
  174. data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
  175. data/ext/libcouchbase/packaging/deb/compat +1 -0
  176. data/ext/libcouchbase/packaging/deb/control +73 -0
  177. data/ext/libcouchbase/packaging/deb/copyright +10 -0
  178. data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
  179. data/ext/libcouchbase/packaging/deb/package.mk +31 -0
  180. data/ext/libcouchbase/packaging/deb/rules +46 -0
  181. data/ext/libcouchbase/packaging/deb/source/format +1 -0
  182. data/ext/libcouchbase/packaging/distinfo/README +1 -0
  183. data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
  184. data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
  185. data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
  186. data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
  187. data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
  188. data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
  189. data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
  190. data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
  191. data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
  192. data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
  193. data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
  194. data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
  195. data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
  196. data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
  197. data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
  198. data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
  199. data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
  200. data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
  201. data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
  202. data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
  203. data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
  204. data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
  205. data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
  206. data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
  207. data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
  208. data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
  209. data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
  210. data/ext/libcouchbase/src/README.md +103 -0
  211. data/ext/libcouchbase/src/aspend.h +106 -0
  212. data/ext/libcouchbase/src/auth.cc +74 -0
  213. data/ext/libcouchbase/src/auth.h +54 -0
  214. data/ext/libcouchbase/src/bootstrap.c +269 -0
  215. data/ext/libcouchbase/src/bootstrap.h +129 -0
  216. data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
  217. data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
  218. data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
  219. data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
  220. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
  221. data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
  222. data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
  223. data/ext/libcouchbase/src/callbacks.c +378 -0
  224. data/ext/libcouchbase/src/cbft.cc +210 -0
  225. data/ext/libcouchbase/src/cntl.cc +847 -0
  226. data/ext/libcouchbase/src/config_static.h +159 -0
  227. data/ext/libcouchbase/src/connspec.cc +462 -0
  228. data/ext/libcouchbase/src/connspec.h +105 -0
  229. data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
  230. data/ext/libcouchbase/src/dump.c +98 -0
  231. data/ext/libcouchbase/src/getconfig.c +100 -0
  232. data/ext/libcouchbase/src/gethrtime.c +109 -0
  233. data/ext/libcouchbase/src/handler.c +922 -0
  234. data/ext/libcouchbase/src/hashset.c +164 -0
  235. data/ext/libcouchbase/src/hashset.h +86 -0
  236. data/ext/libcouchbase/src/hashtable.c +75 -0
  237. data/ext/libcouchbase/src/hdr_timings.c +92 -0
  238. data/ext/libcouchbase/src/hostlist.cc +301 -0
  239. data/ext/libcouchbase/src/hostlist.h +171 -0
  240. data/ext/libcouchbase/src/http/http-priv.h +307 -0
  241. data/ext/libcouchbase/src/http/http.cc +633 -0
  242. data/ext/libcouchbase/src/http/http.h +34 -0
  243. data/ext/libcouchbase/src/http/http_io.cc +307 -0
  244. data/ext/libcouchbase/src/instance.cc +722 -0
  245. data/ext/libcouchbase/src/internal.h +244 -0
  246. data/ext/libcouchbase/src/iofactory.c +575 -0
  247. data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
  248. data/ext/libcouchbase/src/jsparse/parser.h +173 -0
  249. data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
  250. data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
  251. data/ext/libcouchbase/src/lcbio/connect.c +557 -0
  252. data/ext/libcouchbase/src/lcbio/connect.h +364 -0
  253. data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
  254. data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
  255. data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
  256. data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
  257. data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
  258. data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
  259. data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
  260. data/ext/libcouchbase/src/lcbio/manager.c +584 -0
  261. data/ext/libcouchbase/src/lcbio/manager.h +156 -0
  262. data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
  263. data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
  264. data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
  265. data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
  266. data/ext/libcouchbase/src/lcbio/timer.c +132 -0
  267. data/ext/libcouchbase/src/legacy.c +430 -0
  268. data/ext/libcouchbase/src/list.c +144 -0
  269. data/ext/libcouchbase/src/list.h +127 -0
  270. data/ext/libcouchbase/src/logging.c +244 -0
  271. data/ext/libcouchbase/src/logging.h +86 -0
  272. data/ext/libcouchbase/src/mc/compress.c +90 -0
  273. data/ext/libcouchbase/src/mc/compress.h +61 -0
  274. data/ext/libcouchbase/src/mc/forward.c +186 -0
  275. data/ext/libcouchbase/src/mc/forward.h +90 -0
  276. data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
  277. data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
  278. data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
  279. data/ext/libcouchbase/src/mc/mcreq.c +954 -0
  280. data/ext/libcouchbase/src/mc/mcreq.h +977 -0
  281. data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
  282. data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
  283. data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
  284. data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
  285. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
  286. data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
  287. data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
  288. data/ext/libcouchbase/src/n1ql/params.cc +215 -0
  289. data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
  290. data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
  291. data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
  292. data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
  293. data/ext/libcouchbase/src/newconfig.c +385 -0
  294. data/ext/libcouchbase/src/nodeinfo.cc +194 -0
  295. data/ext/libcouchbase/src/operations/cbflush.c +71 -0
  296. data/ext/libcouchbase/src/operations/counter.c +116 -0
  297. data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
  298. data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
  299. data/ext/libcouchbase/src/operations/durability.c +668 -0
  300. data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
  301. data/ext/libcouchbase/src/operations/get.c +409 -0
  302. data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
  303. data/ext/libcouchbase/src/operations/observe.c +340 -0
  304. data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
  305. data/ext/libcouchbase/src/operations/remove.c +83 -0
  306. data/ext/libcouchbase/src/operations/stats.c +461 -0
  307. data/ext/libcouchbase/src/operations/store.c +360 -0
  308. data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
  309. data/ext/libcouchbase/src/operations/touch.c +81 -0
  310. data/ext/libcouchbase/src/packetutils.c +60 -0
  311. data/ext/libcouchbase/src/packetutils.h +147 -0
  312. data/ext/libcouchbase/src/probes.d +211 -0
  313. data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
  314. data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
  315. data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
  316. data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
  317. data/ext/libcouchbase/src/rdb/rope.c +419 -0
  318. data/ext/libcouchbase/src/rdb/rope.h +488 -0
  319. data/ext/libcouchbase/src/retrychk.c +113 -0
  320. data/ext/libcouchbase/src/retryq.c +424 -0
  321. data/ext/libcouchbase/src/retryq.h +157 -0
  322. data/ext/libcouchbase/src/ringbuffer.c +442 -0
  323. data/ext/libcouchbase/src/ringbuffer.h +100 -0
  324. data/ext/libcouchbase/src/settings.c +95 -0
  325. data/ext/libcouchbase/src/settings.h +188 -0
  326. data/ext/libcouchbase/src/simplestring.c +211 -0
  327. data/ext/libcouchbase/src/simplestring.h +228 -0
  328. data/ext/libcouchbase/src/sllist-inl.h +197 -0
  329. data/ext/libcouchbase/src/sllist.h +76 -0
  330. data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
  331. data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
  332. data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
  333. data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
  334. data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
  335. data/ext/libcouchbase/src/ssobuf.h +82 -0
  336. data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
  337. data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
  338. data/ext/libcouchbase/src/timings.c +208 -0
  339. data/ext/libcouchbase/src/trace.h +105 -0
  340. data/ext/libcouchbase/src/utilities.c +171 -0
  341. data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
  342. data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
  343. data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
  344. data/ext/libcouchbase/src/vbucket/hash.h +30 -0
  345. data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
  346. data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
  347. data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
  348. data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
  349. data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
  350. data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
  351. data/ext/libcouchbase/src/views/docreq.c +194 -0
  352. data/ext/libcouchbase/src/views/docreq.h +83 -0
  353. data/ext/libcouchbase/src/views/viewreq.c +358 -0
  354. data/ext/libcouchbase/src/views/viewreq.h +36 -0
  355. data/ext/libcouchbase/src/wait.c +161 -0
  356. data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
  357. data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
  358. data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
  359. data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
  360. data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
  361. data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
  362. data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
  363. data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
  364. data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
  365. data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
  366. data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
  367. data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
  368. data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
  369. data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
  370. data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
  371. data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
  372. data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
  373. data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
  374. data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
  375. data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
  376. data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
  377. data/ext/libcouchbase/tests/check-all.cc +608 -0
  378. data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
  379. data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
  380. data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
  381. data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
  382. data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
  383. data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
  384. data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
  385. data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
  386. data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
  387. data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
  388. data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
  389. data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
  390. data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
  391. data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
  392. data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
  393. data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
  394. data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
  395. data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
  396. data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
  397. data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
  398. data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
  399. data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
  400. data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
  401. data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
  402. data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
  403. data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
  404. data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
  405. data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
  406. data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
  407. data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
  408. data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
  409. data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
  410. data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
  411. data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
  412. data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
  413. data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
  414. data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
  415. data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
  416. data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
  417. data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
  418. data/ext/libcouchbase/tests/mc/mctest.h +119 -0
  419. data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
  420. data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
  421. data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
  422. data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
  423. data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
  424. data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
  425. data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
  426. data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
  427. data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
  428. data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
  429. data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
  430. data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
  431. data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
  432. data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
  433. data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
  434. data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
  435. data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
  436. data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
  437. data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
  438. data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
  439. data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
  440. data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
  441. data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
  442. data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
  443. data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
  444. data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
  445. data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
  446. data/ext/libcouchbase/tests/start_mock.bat +15 -0
  447. data/ext/libcouchbase/tests/start_mock.sh +42 -0
  448. data/ext/libcouchbase/tests/unit_tests.cc +43 -0
  449. data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
  450. data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
  451. data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
  452. data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
  453. data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
  454. data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
  455. data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
  456. data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
  457. data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
  458. data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
  459. data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
  460. data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
  461. data/ext/libcouchbase/tools/cbc.cc +1541 -0
  462. data/ext/libcouchbase/tools/common/histogram.cc +43 -0
  463. data/ext/libcouchbase/tools/common/histogram.h +23 -0
  464. data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
  465. data/ext/libcouchbase/tools/common/options.cc +420 -0
  466. data/ext/libcouchbase/tools/common/options.h +81 -0
  467. data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
  468. data/ext/libcouchbase/tools/docgen/loc.h +210 -0
  469. data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
  470. data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
  471. data/lib/libcouchbase.rb +36 -0
  472. data/lib/libcouchbase/bucket.rb +819 -0
  473. data/lib/libcouchbase/callbacks.rb +72 -0
  474. data/lib/libcouchbase/connection.rb +790 -0
  475. data/lib/libcouchbase/design_docs.rb +86 -0
  476. data/lib/libcouchbase/error.rb +68 -0
  477. data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
  478. data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
  479. data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
  480. data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
  481. data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
  482. data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
  483. data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
  484. data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
  485. data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
  486. data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
  487. data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
  488. data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
  489. data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
  490. data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
  491. data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
  492. data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
  493. data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
  494. data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
  495. data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
  496. data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
  497. data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
  498. data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
  499. data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
  500. data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
  501. data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
  502. data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
  503. data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
  504. data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
  505. data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
  506. data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
  507. data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
  508. data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
  509. data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
  510. data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
  511. data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
  512. data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
  513. data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
  514. data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
  515. data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
  516. data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
  517. data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
  518. data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
  519. data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
  520. data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
  521. data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
  522. data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
  523. data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
  524. data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
  525. data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
  526. data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
  527. data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
  528. data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
  529. data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
  530. data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
  531. data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
  532. data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
  533. data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
  534. data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
  535. data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
  536. data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
  537. data/lib/libcouchbase/ext/tasks.rb +87 -0
  538. data/lib/libcouchbase/n1ql.rb +73 -0
  539. data/lib/libcouchbase/query_full_text.rb +147 -0
  540. data/lib/libcouchbase/query_n1ql.rb +121 -0
  541. data/lib/libcouchbase/query_view.rb +129 -0
  542. data/lib/libcouchbase/results_fiber.rb +262 -0
  543. data/lib/libcouchbase/results_native.rb +211 -0
  544. data/lib/libcouchbase/version.rb +5 -0
  545. data/libcouchbase.gemspec +61 -0
  546. data/spec/bucket_spec.rb +270 -0
  547. data/spec/connection_spec.rb +277 -0
  548. data/spec/design_docs_spec.rb +23 -0
  549. data/spec/error_spec.rb +26 -0
  550. data/spec/fts_spec.rb +129 -0
  551. data/spec/n1ql_spec.rb +201 -0
  552. data/spec/results_libuv_spec.rb +229 -0
  553. data/spec/results_native_spec.rb +259 -0
  554. data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
  555. data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
  556. data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
  557. data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
  558. data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
  559. data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
  560. data/spec/view_spec.rb +195 -0
  561. metadata +775 -0
@@ -0,0 +1,82 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2013 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+
19
+ /**
20
+ * HTTP-based 'REST' configuration. This module works by connecting to the
21
+ * REST API port (and trying various other nodes) until it receives a
22
+ * configuration.
23
+ */
24
+ #ifndef LCB_CLPROVIDER_HTTP_H
25
+ #define LCB_CLPROVIDER_HTTP_H
26
+
27
+ #include "config.h"
28
+ #include "hostlist.h"
29
+ #include "simplestring.h"
30
+ #include "clconfig.h"
31
+ #include <lcbht/lcbht.h>
32
+
33
+ #define REQBUCKET_COMPAT_FMT "GET /pools/default/bucketsStreaming/%s HTTP/1.1\r\n"
34
+ #define REQBUCKET_TERSE_FMT "GET /pools/default/bs/%s HTTP/1.1\r\n"
35
+ #define REQPOOLS_FMT "GET /pools/ HTTP/1.1\r\n"
36
+ #define HOSTHDR_FMT "Host: %s:%s\r\n"
37
+ #define AUTHDR_FMT "Authorization: Basic %s\r\n"
38
+ #define LAST_HTTP_HEADER "X-Libcouchbase: " LCB_VERSION_STRING "\r\n"
39
+ #define CONFIG_DELIMITER "\n\n\n\n"
40
+
41
+ #ifdef __cplusplus
42
+ extern "C" {
43
+ #endif
44
+
45
+ typedef struct clprovider_http_st {
46
+ /** Base configuration structure */
47
+ clconfig_provider base;
48
+ lcbio_pCONNSTART creq;
49
+ lcbio_CTX *ioctx;
50
+ lcbht_pPARSER htp;
51
+
52
+ /**
53
+ * Buffer to use for writing our request header. Recreated for each
54
+ * connection because of the Host: header
55
+ */
56
+ char request_buf[1024];
57
+
58
+ /**
59
+ * We only recreate the connection if our current stream 'times out'. This
60
+ * timer waits until the current stream times out and then proceeds to the
61
+ * next connection.
62
+ */
63
+ lcbio_pTIMER disconn_timer;
64
+ lcbio_pTIMER io_timer;
65
+ lcbio_pTIMER as_reconnect;
66
+
67
+ /** List of hosts to try */
68
+ hostlist_t nodes;
69
+
70
+ /** The cached configuration. */
71
+ clconfig_info *current_config;
72
+ clconfig_info *last_parsed;
73
+ int generation;
74
+ int try_nexturi;
75
+ lcb_HTCONFIG_URLTYPE uritype;
76
+ } http_provider;
77
+
78
+ #ifdef __cplusplus
79
+ }
80
+ #endif
81
+
82
+ #endif /* LCB_CLPROVIDER_HTTP_H */
@@ -0,0 +1,150 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2014 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include <lcbio/lcbio.h>
19
+ #include <lcbio/timer-ng.h>
20
+ #include <libcouchbase/vbucket.h>
21
+ #include "clconfig.h"
22
+
23
+ #define LOGARGS(mcr, lvlbase) mcr->base.parent->settings, "mcraw", LCB_LOG_##lvlbase, __FILE__, __LINE__
24
+ #define LOGFMT "(MCRAW=%p)> "
25
+ #define LOGID(mcr) (void *)mcr
26
+
27
+ /* Raw memcached provider */
28
+
29
+ typedef struct {
30
+ /* Base provider */
31
+ clconfig_provider base;
32
+ /* Current (user defined) configuration */
33
+ clconfig_info *config;
34
+ lcbio_pTIMER async;
35
+ } bc_MCRAW;
36
+
37
+
38
+ static void
39
+ async_update(void *arg)
40
+ {
41
+ bc_MCRAW *mcr = arg;
42
+ if (!mcr->config) {
43
+ lcb_log(LOGARGS(mcr, WARN), "No current config set. Not setting configuration");
44
+ return;
45
+ }
46
+ lcb_confmon_provider_success(&mcr->base, mcr->config);
47
+ }
48
+
49
+ static clconfig_info* get_cached(clconfig_provider *pb) {
50
+ return ((bc_MCRAW *)pb)->config;
51
+ }
52
+ static lcb_error_t get_refresh(clconfig_provider *pb) {
53
+ lcbio_async_signal( ((bc_MCRAW*)pb)->async );
54
+ return LCB_SUCCESS;
55
+ }
56
+ static lcb_error_t pause_mcr(clconfig_provider *pb) {
57
+ (void)pb;
58
+ return LCB_SUCCESS;
59
+ }
60
+
61
+ static void configure_nodes(clconfig_provider *pb, const hostlist_t hl)
62
+ {
63
+ bc_MCRAW *mcr = (bc_MCRAW *)pb;
64
+ lcbvb_SERVER *servers;
65
+ lcbvb_CONFIG *newconfig;
66
+ unsigned ii, nsrv;
67
+
68
+ nsrv = hostlist_size(hl);
69
+
70
+ if (!nsrv) {
71
+ lcb_log(LOGARGS(mcr, FATAL), "No nodes provided");
72
+ return;
73
+ }
74
+
75
+ servers = calloc(nsrv, sizeof(*servers));
76
+ for (ii = 0; ii < nsrv; ii++) {
77
+ int itmp;
78
+ const lcb_host_t *curhost = hostlist_get(hl, ii);
79
+ lcbvb_SERVER *srv = servers + ii;
80
+
81
+ /* just set the memcached port and hostname */
82
+ srv->hostname = (char *)curhost->host;
83
+ sscanf(curhost->port, "%d", &itmp);
84
+ srv->svc.data = itmp;
85
+ if (pb->parent->settings->sslopts) {
86
+ srv->svc_ssl.data = itmp;
87
+ }
88
+ }
89
+
90
+ newconfig = lcbvb_create();
91
+ lcbvb_genconfig_ex(newconfig, "NOBUCKET", "deadbeef", servers, nsrv, 0, 2);
92
+ lcbvb_make_ketama(newconfig);
93
+ newconfig->revid = -1;
94
+
95
+ if (mcr->config) {
96
+ lcb_clconfig_decref(mcr->config);
97
+ mcr->config = NULL;
98
+ }
99
+ mcr->config = lcb_clconfig_create(newconfig, LCB_CLCONFIG_MCRAW);
100
+ mcr->config->cmpclock = gethrtime();
101
+ }
102
+
103
+ lcb_error_t
104
+ lcb_clconfig_mcraw_update(clconfig_provider *pb, const char *nodes)
105
+ {
106
+ lcb_error_t err;
107
+ bc_MCRAW *mcr = (bc_MCRAW *)pb;
108
+ hostlist_t hl = hostlist_create();
109
+ err = hostlist_add_stringz(hl, nodes, LCB_CONFIG_MCCOMPAT_PORT);
110
+ if (err != LCB_SUCCESS) {
111
+ hostlist_destroy(hl);
112
+ return err;
113
+ }
114
+
115
+ configure_nodes(pb, hl);
116
+ hostlist_destroy(hl);
117
+ lcbio_async_signal(mcr->async);
118
+ return LCB_SUCCESS;
119
+ }
120
+
121
+ static void
122
+ mcraw_shutdown(clconfig_provider *pb)
123
+ {
124
+ bc_MCRAW *mcr = (bc_MCRAW *)pb;
125
+ if (mcr->config) {
126
+ lcb_clconfig_decref(mcr->config);
127
+ }
128
+ if (mcr->async) {
129
+ lcbio_timer_destroy(mcr->async);
130
+ }
131
+ free(mcr);
132
+ }
133
+
134
+ clconfig_provider *
135
+ lcb_clconfig_create_mcraw(lcb_confmon *parent)
136
+ {
137
+ bc_MCRAW *mcr = calloc(1, sizeof(*mcr));
138
+ if (!mcr) {
139
+ return NULL;
140
+ }
141
+ mcr->async = lcbio_timer_new(parent->iot, mcr, async_update);
142
+ mcr->base.parent = parent;
143
+ mcr->base.type = LCB_CLCONFIG_MCRAW;
144
+ mcr->base.get_cached = get_cached;
145
+ mcr->base.refresh = get_refresh;
146
+ mcr->base.pause = pause_mcr;
147
+ mcr->base.configure_nodes = configure_nodes;
148
+ mcr->base.shutdown = mcraw_shutdown;
149
+ return &mcr->base;
150
+ }
@@ -0,0 +1,681 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2013 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #ifndef LCB_CLCONFIG_H
19
+ #define LCB_CLCONFIG_H
20
+
21
+ #include "hostlist.h"
22
+ #include "list.h"
23
+ #include "simplestring.h"
24
+ #include <lcbio/timer-ng.h>
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ /** @file */
30
+
31
+ /**
32
+ * @defgroup lcb-confmon Cluster Configuration Management
33
+ *
34
+ * @brief Monitors the retrieval and application of new cluster topology maps
35
+ * (vBucket Configurations)
36
+ *
37
+ * @details
38
+ * This module attempts to implement the 'Configuration Provider' interface
39
+ * described at https://docs.google.com/document/d/1bSMt0Sj1uQtm0OYolQaJDJg4sASfoCEwU6_gjm1he8s/edit
40
+ *
41
+ * The model is fairly complex though significantly more maintainable and
42
+ * testable than the previous model. The basic idea is as follows:
43
+ *
44
+ *
45
+ * <ol>
46
+ *
47
+ * <li>
48
+ * There is a _Configuration Monitor_ object (lcb_confmon) which acts
49
+ * as the configuration supervisor. It is responsible for returning
50
+ * configuration objects to those entities which request it.
51
+ * </li>
52
+ *
53
+ * <li>
54
+ * There are multiple _Configuration Provider_ (clconfig_provider) objects.
55
+ * These providers aggregate configurations from multiple sources and
56
+ * implement a common interface to:
57
+ *
58
+ * <ol>
59
+ * <li>Return a _quick_ configuration without fetching from network or disk
60
+ * (see clconfig_provider::get_cached())</i>
61
+
62
+ * <li>Schedule a refresh to retrieve the latest configuration from the
63
+ * network (see clconfig_provider::refresh())</li>
64
+ *
65
+ * <li>Notify the monitor that it has received a new configuration. The
66
+ * monitor itself will determine whether or not to accept the new
67
+ * configuration by examining the configuration and determining if it is more
68
+ * recent than the one currently in used. See lcb_confmon_set_next()</li>
69
+ * </ol></li>
70
+ *
71
+ * <li>
72
+ * _Configuration Info_ objects. These objects are refcounted wrappers
73
+ * around vbucket configuration handles. They have a refcount and also an
74
+ * integer which can be used to compare with other objects for 'freshness'.
75
+ * See clconfig_info
76
+ * </li>
77
+ *
78
+ * <li>
79
+ * _Configuration Listeners_. These are registered with the global supervisor
80
+ * and are invoked whenever a new valid configuration is detected. This is
81
+ * really only ever used during bootstrap or testing where we are explicitly
82
+ * waiting for a configuration without having any actual commands to schedule.
83
+ * See clconfig_listener
84
+ * </li>
85
+ * </ol>
86
+ */
87
+
88
+ /**
89
+ *@addtogroup lcb-confmon
90
+ *@{
91
+ */
92
+
93
+ /**
94
+ * @brief Enumeration of the various config providers available.
95
+ * The type of methods available. These are enumerated in order of preference
96
+ */
97
+ typedef enum {
98
+ /** Currently unused. The intent here is to allow a user to provide means
99
+ * by which the application may give a configuration file to the library */
100
+ LCB_CLCONFIG_USER,
101
+ /** File-based "configcache" provider. Implemented in bc_file.c */
102
+ LCB_CLCONFIG_FILE,
103
+ /** New-style config-over-memcached provider. Implemented in bc_cccp.c */
104
+ LCB_CLCONFIG_CCCP,
105
+ /** Old-style streaming HTTP provider. Implemented in bc_http.c */
106
+ LCB_CLCONFIG_HTTP,
107
+ /** Raw memcached provided */
108
+ LCB_CLCONFIG_MCRAW,
109
+
110
+ LCB_CLCONFIG_MAX,
111
+
112
+ /** Ephemeral source, used for tests */
113
+ LCB_CLCONFIG_PHONY
114
+ } clconfig_method_t;
115
+
116
+
117
+ struct clconfig_info_st;
118
+ struct clconfig_provider_st;
119
+ struct clconfig_listener_st;
120
+ struct lcb_confmon_st;
121
+
122
+ /**
123
+ * This object contains the information needed for libcouchbase to deal with
124
+ * when retrieving new configs.
125
+ */
126
+ typedef struct lcb_confmon_st {
127
+ /** Linked list of active/enabled providers */
128
+ lcb_clist_t active_providers;
129
+
130
+ /**Current provider. This provider may either fail or succeed.
131
+ * In either case unless the provider can provide us with a specific
132
+ * config which is newer than the one we have, it will roll over to the
133
+ * next provider. */
134
+ struct clconfig_provider_st *cur_provider;
135
+
136
+ /** All providers we know about. Currently this means the 'builtin' providers */
137
+ struct clconfig_provider_st * all_providers[LCB_CLCONFIG_MAX];
138
+
139
+ /** The current configuration pointer. This contains the most recent accepted
140
+ * configuration */
141
+ struct clconfig_info_st * config;
142
+
143
+ /* CONFMON_S_* values. Used internally */
144
+ int state;
145
+
146
+ /** Last time the provider was stopped. As a microsecond timestamp */
147
+ lcb_uint32_t last_stop_us;
148
+
149
+ /** This is the async handle for a reentrant start */
150
+ lcbio_pTIMER as_start;
151
+
152
+ /** Async handle for a reentrant stop */
153
+ lcbio_pTIMER as_stop;
154
+
155
+ /** List of listeners for events */
156
+ lcb_list_t listeners;
157
+ lcb_settings *settings;
158
+ lcb_error_t last_error;
159
+ lcbio_pTABLE iot;
160
+ } lcb_confmon;
161
+
162
+ /**
163
+ * The base structure of a provider. This structure is intended to be
164
+ * 'subclassed' by implementors.
165
+ */
166
+ typedef struct clconfig_provider_st {
167
+ lcb_list_t ll; /**< Node in linked list of active providers (if active) */
168
+
169
+ /** The type of provider */
170
+ clconfig_method_t type;
171
+
172
+ /** Whether this provider has been disabled/enabled explicitly by a user */
173
+ int enabled;
174
+
175
+ /** The parent manager object */
176
+ struct lcb_confmon_st *parent;
177
+
178
+ /**
179
+ * Get the current map known to this provider. This should not perform
180
+ * any blocking operations. Providers which use a push model may use
181
+ * this method as an asynchronous return value for a previously-received
182
+ * configuration.
183
+ *
184
+ * @param pb
185
+ */
186
+ struct clconfig_info_st* (*get_cached)(struct clconfig_provider_st *pb);
187
+
188
+
189
+ /**
190
+ * Request a new configuration. This will be called by the manager when
191
+ * the cached configuration (i.e. 'get_cached') is deemed invalid. Thus
192
+ * this function should unconditionally try to schedule getting the
193
+ * newest configuration it can. When the configuration has been received,
194
+ * the provider may call provider_success or provider_failed.
195
+ *
196
+ * @note
197
+ * The PROVIDER is responsible for terminating its own
198
+ * process. In other words there is no safeguard within confmon itself
199
+ * against a provider taking an excessively long time; therefore a provider
200
+ * should implement a timeout mechanism of its choice to promptly deliver
201
+ * a success or failure.
202
+ *
203
+ * @param pb
204
+ */
205
+ lcb_error_t (*refresh)(struct clconfig_provider_st *pb);
206
+
207
+ /**
208
+ * Callback invoked to the provider to indicate that it should cease
209
+ * performing any "Active" configuration changes. Note that this is only
210
+ * a hint and a provider may perform its own hooking based on this. In any
211
+ * event receiving this callback is indicating that the provider will not
212
+ * be needed again in quite some time. How long this "time" is can range
213
+ * between 0 seconds and several minutes depending on how a user has
214
+ * configured the client.
215
+ * @param pb
216
+ */
217
+ lcb_error_t (*pause)(struct clconfig_provider_st *pb);
218
+
219
+ /**
220
+ * Called when a new configuration has been received.
221
+ *
222
+ * @param provider the provider instance
223
+ * @param config the current configuration.
224
+ * Note that this should only update the server list and do nothing
225
+ * else.
226
+ */
227
+ void (*config_updated)(struct clconfig_provider_st *provider,
228
+ lcbvb_CONFIG* config);
229
+
230
+ /**
231
+ * Retrieve the list of nodes from this provider, if applicable
232
+ * @param p the provider
233
+ * @return A list of nodes, or NULL if the provider does not have a list
234
+ */
235
+ hostlist_t (*get_nodes)(const struct clconfig_provider_st *p);
236
+
237
+ /**
238
+ * Call to change the configured nodes of this provider.
239
+ * @param p The provider
240
+ * @param l The list of nodes to apply
241
+ */
242
+ void (*configure_nodes)(struct clconfig_provider_st *p, const hostlist_t l);
243
+
244
+ /** Destroy the resources created by this provider. */
245
+ void (*shutdown)(struct clconfig_provider_st *);
246
+
247
+ /**
248
+ * Dump state information. This callback is optional
249
+ * @param p the provider
250
+ * @param f the file to write to
251
+ */
252
+ void (*dump)(struct clconfig_provider_st *p, FILE *f);
253
+ } clconfig_provider;
254
+
255
+
256
+ /** @brief refcounted object encapsulating a vbucket config */
257
+ typedef struct clconfig_info_st {
258
+ /** Actual configuration */
259
+ lcbvb_CONFIG* vbc;
260
+
261
+ /** Comparative clock with which to compare */
262
+ lcb_uint64_t cmpclock;
263
+
264
+ /** Reference counter */
265
+ unsigned int refcount;
266
+
267
+ /** Origin provider type which produced this config */
268
+ clconfig_method_t origin;
269
+ } clconfig_info;
270
+
271
+ /** Event types propagated to listeners */
272
+ typedef enum {
273
+ /** Called when a new configuration is being set in confmon */
274
+ CLCONFIG_EVENT_GOT_NEW_CONFIG,
275
+
276
+ /** Called when _any_ configuration is received via set_enxt */
277
+ CLCONFIG_EVENT_GOT_ANY_CONFIG,
278
+
279
+ /** Called when all providers have been tried */
280
+ CLCONFIG_EVENT_PROVIDERS_CYCLED,
281
+
282
+ /** The monitor has stopped */
283
+ CLCONFIG_EVENT_MONITOR_STOPPED
284
+ } clconfig_event_t;
285
+
286
+ /**
287
+ * @brief Listener for events
288
+ * One or more listeners may be installed into the confmon which will have
289
+ * a callback invoked on significant vbucket events. See clconfig_event_t
290
+ * for a variety of events the listener can know.
291
+ */
292
+ typedef struct clconfig_listener_st {
293
+ /** Linked list node */
294
+ lcb_list_t ll;
295
+
296
+ /** Monitor object */
297
+ lcb_confmon *parent;
298
+
299
+ /**
300
+ * Callback invoked for significant events
301
+ *
302
+ * @param lsn the listener structure itself
303
+ * @param event the event which took place
304
+ * @param config the configuration associated with the event. Note that
305
+ * `config` may also be NULL
306
+ */
307
+ void (*callback)(struct clconfig_listener_st *lsn, clconfig_event_t event,
308
+ struct clconfig_info_st *config);
309
+
310
+ } clconfig_listener;
311
+
312
+ /* Method-specific setup methods.. */
313
+
314
+ clconfig_provider * lcb_clconfig_create_http(lcb_confmon *mon);
315
+ clconfig_provider * lcb_clconfig_create_cccp(lcb_confmon *mon);
316
+ clconfig_provider * lcb_clconfig_create_file(lcb_confmon *mon);
317
+ clconfig_provider * lcb_clconfig_create_user(lcb_confmon *mon);
318
+ clconfig_provider * lcb_clconfig_create_mcraw(lcb_confmon *mon);
319
+
320
+ /**@brief Get a provider by its type
321
+ * @param mon the monitor
322
+ * @param ix a clconfig_method_t indicating the type of provider to fetch
323
+ * @return a pointer to the provider of the given type
324
+ */
325
+ #define lcb_confmon_get_provider(mon, ix) (mon)->all_providers[ix]
326
+
327
+ /**
328
+ * @brief Macro used to retrieve a setting from a provider
329
+ * @param p the provider pointer
330
+ * @param n the name of the setting field to retrieve as token
331
+ */
332
+ #define PROVIDER_SETTING(p, n) ((p)->parent->settings->n)
333
+
334
+ /**
335
+ * @brief Macro used by a provider to set the failure code in the parent
336
+ * lcb_confmon object
337
+ * @param p the provider pointer
338
+ * @param e the error code
339
+ */
340
+ #define PROVIDER_SET_ERROR(p, e) (p)->parent->last_error = e
341
+
342
+ /**
343
+ * @brief Create a new configuration monitor.
344
+ * This function creates a new `confmon` object which can be used to manage
345
+ * configurations and their providers.
346
+ *
347
+ * @param settings
348
+ * @param iot
349
+ *
350
+ * Once the confmon object has been created you may enable or disable various
351
+ * providers (see lcb_confmon_set_provider_active()). Once no more providers
352
+ * remain to be activated you should call lcb_confmon_prepare() once. Then
353
+ * call the rest of the functions.
354
+ */
355
+ LIBCOUCHBASE_API
356
+ lcb_confmon *
357
+ lcb_confmon_create(lcb_settings *settings, lcbio_pTABLE iot);
358
+
359
+ /**Destroy the confmon object.
360
+ * @param mon */
361
+ LIBCOUCHBASE_API
362
+ void
363
+ lcb_confmon_destroy(lcb_confmon *mon);
364
+
365
+ /**
366
+ * Prepares the configuration monitor object for operations. This will insert
367
+ * all the enabled providers into a list. Call this function each time a
368
+ * provider has been enabled.
369
+ * @param mon
370
+ */
371
+ LIBCOUCHBASE_API
372
+ void
373
+ lcb_confmon_prepare(lcb_confmon *mon);
374
+
375
+ LCB_INTERNAL_API
376
+ void
377
+ lcb_confmon_set_provider_active(lcb_confmon *mon,
378
+ clconfig_method_t type, int enabled);
379
+
380
+
381
+ /**
382
+ * @brief Request a configuration refresh
383
+ *
384
+ * Start traversing the list of current providers, requesting a new
385
+ * configuration for each. This function will asynchronously loop through all
386
+ * providers until one provides a new configuration.
387
+ *
388
+ * You may call lcb_confmon_stop() to asynchronously break out of the loop.
389
+ * If the confmon is already in a refreshing state
390
+ * (i.e. lcb_confmon_is_refreshing()) returns true then this function does
391
+ * nothing.
392
+ *
393
+ * This function is reentrant safe and may be called at any time.
394
+ *
395
+ * @param mon
396
+ * @see lcb_confmon_add_listener()
397
+ * @see lcb_confmon_stop()
398
+ * @see lcb_confmon_is_refreshing()
399
+ */
400
+ LIBCOUCHBASE_API
401
+ lcb_error_t lcb_confmon_start(lcb_confmon *mon);
402
+
403
+ /**
404
+ * @brief Cancel a pending configuration refresh.
405
+ *
406
+ * Stops the monitor. This will call clconfig_provider::pause() for each active
407
+ * provider. Typically called before destruction or when a new configuration
408
+ * has been found.
409
+ *
410
+ * This function is safe to call anywhere. If the monitor is already stopped
411
+ * then this function does nothing.
412
+ *
413
+ * @param mon
414
+ * @see lcb_confmon_start()
415
+ * @see lcb_confmon_is_refreshing()
416
+ */
417
+ LIBCOUCHBASE_API
418
+ lcb_error_t lcb_confmon_stop(lcb_confmon *mon);
419
+
420
+ /**
421
+ * @brief Check if the monitor is waiting for a new config from a provider
422
+ * @param mon
423
+ * @return true if refreshing, false if idle
424
+ */
425
+ LCB_INTERNAL_API
426
+ int lcb_confmon_is_refreshing(lcb_confmon *mon);
427
+
428
+
429
+ /**@brief Get the current configuration object
430
+ * @return The current configuration */
431
+ #define lcb_confmon_get_config(mon) (mon)->config
432
+
433
+ /**@brief Get the last error code set by a provider
434
+ * @return the last error code (if failure) */
435
+ #define lcb_confmon_last_error(mon) (mon)->last_error
436
+
437
+ /**
438
+ * @brief Indicate that a provider has failed and advance the monitor
439
+ *
440
+ * Indicate that the current provider has failed to obtain a new configuration.
441
+ * This is always called by a provider and should be invoked when the provider
442
+ * has encountered an internal error which caused it to be unable to fetch
443
+ * the configuration.
444
+ *
445
+ * Note that this function is safe to call from any provider at any time. If
446
+ * the provider is not the current provider then it is treated as an async
447
+ * push notification failure and ignored. This function is _not_ safe to call
448
+ * from consumers of providers
449
+ *
450
+ * Once this is called, the confmon instance will either roll over to the next
451
+ * provider or enter the inactive state depending on the configuration and
452
+ * whether the current provider is the last provider in the list.
453
+ *
454
+ * @param provider
455
+ * @param err
456
+ */
457
+ LIBCOUCHBASE_API
458
+ void
459
+ lcb_confmon_provider_failed(clconfig_provider *provider, lcb_error_t err);
460
+
461
+
462
+ /**
463
+ * @brief Indicate that a provider has successfuly retrieved a configuration.
464
+ *
465
+ * Indicates that the provider has fetched a new configuration from the network
466
+ * and that confmon should attempt to propagate it. It has similar semantics
467
+ * to lcb_confmon_provider_failed() except that the second argument is a config
468
+ * object rather than an error code. The second argument must not be `NULL`
469
+ *
470
+ * The monitor will compare the new config against the current config.
471
+ * If the new config does not feature any changes from the current config then
472
+ * it is ignored and the confmon instance will proceed to the next provider.
473
+ * This is done through a direct call to provider_failed(provider, LCB_SUCCESS).
474
+ *
475
+ * This function should _not_ be called outside of an asynchronous provider's
476
+ * handler.
477
+ *
478
+ * @param provider the provider which yielded the new configuration
479
+ * @param info the new configuration
480
+ */
481
+ LIBCOUCHBASE_API
482
+ void
483
+ lcb_confmon_provider_success(clconfig_provider *provider, clconfig_info *info);
484
+
485
+ /**
486
+ * @brief Register a listener to be invoked on state changes and events
487
+ *
488
+ * Adds a 'listener' object to be called at each configuration update. The
489
+ * listener may co-exist with other listeners (though it should never be added
490
+ * twice). When a new configuration is received and accept, the listener's
491
+ * clconfig_listener::callback field will be invoked with it.
492
+ *
493
+ * The callback will continue to be invoked for each new configuration received
494
+ * until remove_listener is called. Note that the listener is not allocated
495
+ * by the confmon and its responsibility is the user's
496
+ *
497
+ * @param mon the monitor
498
+ * @param listener the listener. The listener's contents are not copied into
499
+ * confmon and should thus remain valid until it is removed
500
+ */
501
+ LIBCOUCHBASE_API
502
+ void lcb_confmon_add_listener(lcb_confmon *mon, clconfig_listener *listener);
503
+
504
+ /**
505
+ * @brief Unregister (and remove) a listener added via lcb_confmon_add_listener()
506
+ * @param mon the monitor
507
+ * @param listener the listener
508
+ */
509
+ LIBCOUCHBASE_API
510
+ void lcb_confmon_remove_listener(lcb_confmon *mon, clconfig_listener *listener);
511
+
512
+ /** @brief Possible confmon states */
513
+ typedef enum {
514
+ /** The monitor is idle and not requesting a new configuration */
515
+ CONFMON_S_INACTIVE = 0,
516
+
517
+ /** The monitor is actively requesting a configuration */
518
+ CONFMON_S_ACTIVE = 1 << 0,
519
+
520
+ /** The monitor is fetching a configuration, but is in a throttle state */
521
+ CONFMON_S_ITERGRACE = 1 << 1
522
+ } confmon_state_t;
523
+
524
+ /**
525
+ * @brief Get the current monitor state
526
+ * @param mon the monitor
527
+ * @return a set of flags consisting of confmon_state_t values.
528
+ */
529
+ #define lcb_confmon_get_state(mon) (mon)->state
530
+
531
+ /**
532
+ * Creates a new configuration wrapper object containing the vbucket config
533
+ * pointed to by 'config'. Its initial refcount will be set to 1.
534
+ *
535
+ * @param config a newly parsed configuration
536
+ * @param origin the type of provider from which the config originated.
537
+ */
538
+ clconfig_info *
539
+ lcb_clconfig_create(lcbvb_CONFIG* config, clconfig_method_t origin);
540
+
541
+ /**
542
+ * @brief Compares two info structures and determine which one is newer
543
+ *
544
+ * This function returns an integer less than
545
+ * zero, zero or greater than zero if the first argument is considered older
546
+ * than, equal to, or later than the second argument.
547
+ * @param a
548
+ * @param b
549
+ * @see lcbvb_get_revision
550
+ * @see clconfig_info::cmpclock
551
+ */
552
+ LIBCOUCHBASE_API
553
+ int lcb_clconfig_compare(const clconfig_info *a, const clconfig_info *b);
554
+
555
+ /**
556
+ * @brief Decrement the refcount on a config object.
557
+ * Decrement the refcount. If the internal refcount reaches 0 then the internal
558
+ * members (including the vbucket config handle itself) will be freed.
559
+ * @param info the configuration
560
+ */
561
+ void lcb_clconfig_decref(clconfig_info *info);
562
+
563
+ /**
564
+ * @brief Increment the refcount on a config object
565
+ * @param info the config object
566
+ */
567
+ #define lcb_clconfig_incref(info) (info)->refcount++
568
+
569
+ /** Dump information about the monitor
570
+ * @param mon the monitor object
571
+ * @param fp the file to which information should be written
572
+ */
573
+ void lcb_confmon_dump(lcb_confmon *mon, FILE *fp);
574
+
575
+ /**
576
+ * @name File Provider-specific APIs
577
+ * @{
578
+ */
579
+
580
+ /**
581
+ * Sets the input/output filename for the file provider. This also enables
582
+ * the file provider.
583
+ * @param p the provider
584
+ * @param f the filename (if NULL, a temporary filename will be created)
585
+ * @param ro whether the client will never modify the file
586
+ * @return zero on success, nonzero on failure.
587
+ */
588
+ int lcb_clconfig_file_set_filename(clconfig_provider *p, const char *f, int ro);
589
+
590
+ /**
591
+ * Retrieve the filename for the provider
592
+ * @param p The provider of type LCB_CLCONFIG_FILE
593
+ * @return the current filename being used.
594
+ */
595
+ const char * lcb_clconfig_file_get_filename(clconfig_provider *p);
596
+
597
+ void lcb_clconfig_file_set_readonly(clconfig_provider *p, int val);
598
+ /**@}*/
599
+
600
+ /**
601
+ * @name HTTP Provider-specific APIs
602
+ * @{
603
+ */
604
+
605
+ /**
606
+ * Get the socket representing the current REST connection to the cluster
607
+ * (if applicable)
608
+ * @param mon
609
+ * @return
610
+ */
611
+ lcbio_SOCKET* lcb_confmon_get_rest_connection(lcb_confmon *mon);
612
+
613
+ /**
614
+ * Get the hostname for the current REST connection to the cluster
615
+ * @param mon
616
+ * @return
617
+ */
618
+ lcb_host_t * lcb_confmon_get_rest_host(lcb_confmon *mon);
619
+
620
+ /**
621
+ * Enables the HTTP provider
622
+ * @param pb a provider of type LCB_CLCONFIG_HTTP
623
+ */
624
+ LCB_INTERNAL_API
625
+ void lcb_clconfig_http_enable(clconfig_provider *pb);
626
+ #define lcb_clconfig_http_set_nodes lcb_clconfig_cccp_set_nodes
627
+ /**@}*/
628
+
629
+ /**
630
+ * @name CCCP Provider-specific APIs
631
+ * @{
632
+ */
633
+ LCB_INTERNAL_API
634
+ void lcb_clconfig_cccp_enable(clconfig_provider *pb, lcb_t instance);
635
+
636
+ /**
637
+ * @brief Notify the CCCP provider about a new configuration from a
638
+ * `NOT_MY_VBUCKET` response
639
+ *
640
+ * This should be called by the packet handler when a configuration has been
641
+ * received as a payload to a response with the error of `NOT_MY_VBUCKET`.
642
+ *
643
+ * @param provider The CCCP provider
644
+ * @param host The hostname (without the port) on which the packet was received
645
+ * @param data The configuration JSON blob
646
+ * @return LCB_SUCCESS, or an error code if the configuration could not be
647
+ * set
648
+ */
649
+ lcb_error_t
650
+ lcb_cccp_update(clconfig_provider *provider, const char *host, lcb_string *data);
651
+
652
+ /**
653
+ * @brief Notify the CCCP provider about a configuration received from a
654
+ * `CMD_GET_CLUSTER_CONFIG` response.
655
+ *
656
+ * @param cookie The cookie object attached to the packet
657
+ * @param err The error code for the reply
658
+ * @param bytes The payload pointer
659
+ * @param nbytes Size of payload
660
+ * @param origin Host object from which the packet was received
661
+ */
662
+ void
663
+ lcb_cccp_update2(const void *cookie, lcb_error_t err,
664
+ const void *bytes, lcb_size_t nbytes, const lcb_host_t *origin);
665
+
666
+ #define lcb_clconfig_cccp_set_nodes(pb, nodes) (pb)->configure_nodes(pb, nodes)
667
+ /**@}*/
668
+
669
+ /**@name Raw Memcached (MCRAW) Provider-specific APIs
670
+ * @{*/
671
+ LCB_INTERNAL_API
672
+ lcb_error_t
673
+ lcb_clconfig_mcraw_update(clconfig_provider *pb, const char *nodes);
674
+ /**@}*/
675
+
676
+ /**@}*/
677
+
678
+ #ifdef __cplusplus
679
+ }
680
+ #endif /* __cplusplus */
681
+ #endif /* LCB_CLCONFIG_H */