libcouchbase 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +389 -0
- data/Rakefile +75 -0
- data/ext/README.md +6 -0
- data/ext/Rakefile +20 -0
- data/ext/libcouchbase/.gitignore +130 -0
- data/ext/libcouchbase/.travis.yml +19 -0
- data/ext/libcouchbase/CMakeLists.txt +429 -0
- data/ext/libcouchbase/CONTRIBUTING.md +124 -0
- data/ext/libcouchbase/LICENSE +202 -0
- data/ext/libcouchbase/README.markdown +163 -0
- data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
- data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
- data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
- data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
- data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
- data/ext/libcouchbase/cmake/configure +357 -0
- data/ext/libcouchbase/cmake/defs.mk.in +8 -0
- data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
- data/ext/libcouchbase/cmake/source_files.cmake +73 -0
- data/ext/libcouchbase/configure.pl +1 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
- data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
- data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
- data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
- data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
- data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
- data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
- data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
- data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
- data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
- data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
- data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
- data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
- data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
- data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
- data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
- data/ext/libcouchbase/example/CMakeLists.txt +37 -0
- data/ext/libcouchbase/example/README.markdown +47 -0
- data/ext/libcouchbase/example/db/db.c +167 -0
- data/ext/libcouchbase/example/db/vb.c +227 -0
- data/ext/libcouchbase/example/instancepool/main.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.h +69 -0
- data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
- data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
- data/ext/libcouchbase/example/minimal/minimal.c +130 -0
- data/ext/libcouchbase/example/observe/observe.c +146 -0
- data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
- data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
- data/ext/libcouchbase/example/tick/tick.c +119 -0
- data/ext/libcouchbase/example/views/views-example.cc +83 -0
- data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
- data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
- data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
- data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
- data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
- data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
- data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
- data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
- data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
- data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
- data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
- data/ext/libcouchbase/include/memcached/COPYING +30 -0
- data/ext/libcouchbase/include/memcached/README +10 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/README +7 -0
- data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
- data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
- data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
- data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
- data/ext/libcouchbase/packaging/deb/compat +1 -0
- data/ext/libcouchbase/packaging/deb/control +73 -0
- data/ext/libcouchbase/packaging/deb/copyright +10 -0
- data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
- data/ext/libcouchbase/packaging/deb/package.mk +31 -0
- data/ext/libcouchbase/packaging/deb/rules +46 -0
- data/ext/libcouchbase/packaging/deb/source/format +1 -0
- data/ext/libcouchbase/packaging/distinfo/README +1 -0
- data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
- data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
- data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
- data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
- data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
- data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
- data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
- data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
- data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
- data/ext/libcouchbase/src/README.md +103 -0
- data/ext/libcouchbase/src/aspend.h +106 -0
- data/ext/libcouchbase/src/auth.cc +74 -0
- data/ext/libcouchbase/src/auth.h +54 -0
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +129 -0
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/callbacks.c +378 -0
- data/ext/libcouchbase/src/cbft.cc +210 -0
- data/ext/libcouchbase/src/cntl.cc +847 -0
- data/ext/libcouchbase/src/config_static.h +159 -0
- data/ext/libcouchbase/src/connspec.cc +462 -0
- data/ext/libcouchbase/src/connspec.h +105 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
- data/ext/libcouchbase/src/dump.c +98 -0
- data/ext/libcouchbase/src/getconfig.c +100 -0
- data/ext/libcouchbase/src/gethrtime.c +109 -0
- data/ext/libcouchbase/src/handler.c +922 -0
- data/ext/libcouchbase/src/hashset.c +164 -0
- data/ext/libcouchbase/src/hashset.h +86 -0
- data/ext/libcouchbase/src/hashtable.c +75 -0
- data/ext/libcouchbase/src/hdr_timings.c +92 -0
- data/ext/libcouchbase/src/hostlist.cc +301 -0
- data/ext/libcouchbase/src/hostlist.h +171 -0
- data/ext/libcouchbase/src/http/http-priv.h +307 -0
- data/ext/libcouchbase/src/http/http.cc +633 -0
- data/ext/libcouchbase/src/http/http.h +34 -0
- data/ext/libcouchbase/src/http/http_io.cc +307 -0
- data/ext/libcouchbase/src/instance.cc +722 -0
- data/ext/libcouchbase/src/internal.h +244 -0
- data/ext/libcouchbase/src/iofactory.c +575 -0
- data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
- data/ext/libcouchbase/src/jsparse/parser.h +173 -0
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +364 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
- data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
- data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
- data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
- data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
- data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
- data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
- data/ext/libcouchbase/src/lcbio/manager.c +584 -0
- data/ext/libcouchbase/src/lcbio/manager.h +156 -0
- data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
- data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
- data/ext/libcouchbase/src/lcbio/timer.c +132 -0
- data/ext/libcouchbase/src/legacy.c +430 -0
- data/ext/libcouchbase/src/list.c +144 -0
- data/ext/libcouchbase/src/list.h +127 -0
- data/ext/libcouchbase/src/logging.c +244 -0
- data/ext/libcouchbase/src/logging.h +86 -0
- data/ext/libcouchbase/src/mc/compress.c +90 -0
- data/ext/libcouchbase/src/mc/compress.h +61 -0
- data/ext/libcouchbase/src/mc/forward.c +186 -0
- data/ext/libcouchbase/src/mc/forward.h +90 -0
- data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
- data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
- data/ext/libcouchbase/src/mc/mcreq.c +954 -0
- data/ext/libcouchbase/src/mc/mcreq.h +977 -0
- data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
- data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
- data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
- data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
- data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
- data/ext/libcouchbase/src/n1ql/params.cc +215 -0
- data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
- data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
- data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
- data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
- data/ext/libcouchbase/src/newconfig.c +385 -0
- data/ext/libcouchbase/src/nodeinfo.cc +194 -0
- data/ext/libcouchbase/src/operations/cbflush.c +71 -0
- data/ext/libcouchbase/src/operations/counter.c +116 -0
- data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
- data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
- data/ext/libcouchbase/src/operations/durability.c +668 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
- data/ext/libcouchbase/src/operations/get.c +409 -0
- data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
- data/ext/libcouchbase/src/operations/observe.c +340 -0
- data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
- data/ext/libcouchbase/src/operations/remove.c +83 -0
- data/ext/libcouchbase/src/operations/stats.c +461 -0
- data/ext/libcouchbase/src/operations/store.c +360 -0
- data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
- data/ext/libcouchbase/src/operations/touch.c +81 -0
- data/ext/libcouchbase/src/packetutils.c +60 -0
- data/ext/libcouchbase/src/packetutils.h +147 -0
- data/ext/libcouchbase/src/probes.d +211 -0
- data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
- data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
- data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
- data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
- data/ext/libcouchbase/src/rdb/rope.c +419 -0
- data/ext/libcouchbase/src/rdb/rope.h +488 -0
- data/ext/libcouchbase/src/retrychk.c +113 -0
- data/ext/libcouchbase/src/retryq.c +424 -0
- data/ext/libcouchbase/src/retryq.h +157 -0
- data/ext/libcouchbase/src/ringbuffer.c +442 -0
- data/ext/libcouchbase/src/ringbuffer.h +100 -0
- data/ext/libcouchbase/src/settings.c +95 -0
- data/ext/libcouchbase/src/settings.h +188 -0
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/sllist-inl.h +197 -0
- data/ext/libcouchbase/src/sllist.h +76 -0
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
- data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
- data/ext/libcouchbase/src/timings.c +208 -0
- data/ext/libcouchbase/src/trace.h +105 -0
- data/ext/libcouchbase/src/utilities.c +171 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
- data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
- data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
- data/ext/libcouchbase/src/vbucket/hash.h +30 -0
- data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
- data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
- data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
- data/ext/libcouchbase/src/views/docreq.c +194 -0
- data/ext/libcouchbase/src/views/docreq.h +83 -0
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +36 -0
- data/ext/libcouchbase/src/wait.c +161 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
- data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
- data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
- data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
- data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
- data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
- data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
- data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
- data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
- data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
- data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
- data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
- data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
- data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
- data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
- data/ext/libcouchbase/tests/check-all.cc +608 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
- data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
- data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
- data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
- data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
- data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
- data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
- data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
- data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
- data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
- data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
- data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
- data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
- data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
- data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
- data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
- data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
- data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
- data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
- data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
- data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
- data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
- data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
- data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
- data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
- data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
- data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
- data/ext/libcouchbase/tests/mc/mctest.h +119 -0
- data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
- data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
- data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
- data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
- data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
- data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
- data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
- data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
- data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
- data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
- data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
- data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
- data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
- data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
- data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
- data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
- data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
- data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
- data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
- data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
- data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
- data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
- data/ext/libcouchbase/tests/start_mock.bat +15 -0
- data/ext/libcouchbase/tests/start_mock.sh +42 -0
- data/ext/libcouchbase/tests/unit_tests.cc +43 -0
- data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
- data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
- data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
- data/ext/libcouchbase/tools/cbc.cc +1541 -0
- data/ext/libcouchbase/tools/common/histogram.cc +43 -0
- data/ext/libcouchbase/tools/common/histogram.h +23 -0
- data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
- data/ext/libcouchbase/tools/common/options.cc +420 -0
- data/ext/libcouchbase/tools/common/options.h +81 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
- data/ext/libcouchbase/tools/docgen/loc.h +210 -0
- data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
- data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
- data/lib/libcouchbase.rb +36 -0
- data/lib/libcouchbase/bucket.rb +819 -0
- data/lib/libcouchbase/callbacks.rb +72 -0
- data/lib/libcouchbase/connection.rb +790 -0
- data/lib/libcouchbase/design_docs.rb +86 -0
- data/lib/libcouchbase/error.rb +68 -0
- data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
- data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
- data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
- data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
- data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
- data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
- data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
- data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
- data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
- data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
- data/lib/libcouchbase/ext/tasks.rb +87 -0
- data/lib/libcouchbase/n1ql.rb +73 -0
- data/lib/libcouchbase/query_full_text.rb +147 -0
- data/lib/libcouchbase/query_n1ql.rb +121 -0
- data/lib/libcouchbase/query_view.rb +129 -0
- data/lib/libcouchbase/results_fiber.rb +262 -0
- data/lib/libcouchbase/results_native.rb +211 -0
- data/lib/libcouchbase/version.rb +5 -0
- data/libcouchbase.gemspec +61 -0
- data/spec/bucket_spec.rb +270 -0
- data/spec/connection_spec.rb +277 -0
- data/spec/design_docs_spec.rb +23 -0
- data/spec/error_spec.rb +26 -0
- data/spec/fts_spec.rb +129 -0
- data/spec/n1ql_spec.rb +201 -0
- data/spec/results_libuv_spec.rb +229 -0
- data/spec/results_native_spec.rb +259 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
- data/spec/view_spec.rb +195 -0
- 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 */
|