couchbase 3.0.0.alpha.1 → 3.0.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests-6.0.3.yml +49 -0
  3. data/.github/workflows/tests.yml +47 -0
  4. data/.gitmodules +3 -0
  5. data/.idea/dictionaries/gem_terms.xml +5 -0
  6. data/.idea/inspectionProfiles/Project_Default.xml +1 -0
  7. data/.idea/vcs.xml +1 -0
  8. data/Gemfile +1 -0
  9. data/README.md +55 -2
  10. data/Rakefile +18 -0
  11. data/bin/init-cluster +62 -0
  12. data/bin/setup +1 -0
  13. data/couchbase.gemspec +3 -2
  14. data/examples/crud.rb +1 -2
  15. data/examples/managing_buckets.rb +47 -0
  16. data/examples/managing_collections.rb +58 -0
  17. data/examples/managing_query_indexes.rb +63 -0
  18. data/examples/query.rb +3 -2
  19. data/examples/query_with_consistency.rb +76 -0
  20. data/examples/subdocument.rb +23 -1
  21. data/ext/.clang-format +1 -1
  22. data/ext/.idea/dictionaries/couchbase_terms.xml +2 -0
  23. data/ext/.idea/vcs.xml +1 -0
  24. data/ext/CMakeLists.txt +30 -12
  25. data/ext/build_version.hxx.in +26 -0
  26. data/ext/couchbase/bucket.hxx +69 -8
  27. data/ext/couchbase/cluster.hxx +70 -54
  28. data/ext/couchbase/collections_manifest.hxx +3 -3
  29. data/ext/couchbase/configuration.hxx +14 -0
  30. data/ext/couchbase/couchbase.cxx +2044 -383
  31. data/ext/couchbase/{operations/document_id.hxx → document_id.hxx} +5 -4
  32. data/ext/couchbase/io/http_message.hxx +5 -1
  33. data/ext/couchbase/io/http_parser.hxx +2 -1
  34. data/ext/couchbase/io/http_session.hxx +6 -3
  35. data/ext/couchbase/io/{binary_message.hxx → mcbp_message.hxx} +15 -12
  36. data/ext/couchbase/io/mcbp_parser.hxx +99 -0
  37. data/ext/couchbase/io/{key_value_session.hxx → mcbp_session.hxx} +200 -95
  38. data/ext/couchbase/io/session_manager.hxx +37 -22
  39. data/ext/couchbase/mutation_token.hxx +2 -1
  40. data/ext/couchbase/operations.hxx +38 -8
  41. data/ext/couchbase/operations/bucket_create.hxx +138 -0
  42. data/ext/couchbase/operations/bucket_drop.hxx +65 -0
  43. data/ext/couchbase/operations/bucket_flush.hxx +65 -0
  44. data/ext/couchbase/operations/bucket_get.hxx +69 -0
  45. data/ext/couchbase/operations/bucket_get_all.hxx +62 -0
  46. data/ext/couchbase/operations/bucket_settings.hxx +111 -0
  47. data/ext/couchbase/operations/bucket_update.hxx +115 -0
  48. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +60 -0
  49. data/ext/couchbase/operations/collection_create.hxx +86 -0
  50. data/ext/couchbase/operations/collection_drop.hxx +82 -0
  51. data/ext/couchbase/operations/command.hxx +10 -10
  52. data/ext/couchbase/operations/document_decrement.hxx +80 -0
  53. data/ext/couchbase/operations/document_exists.hxx +80 -0
  54. data/ext/couchbase/operations/{get.hxx → document_get.hxx} +4 -2
  55. data/ext/couchbase/operations/document_get_and_lock.hxx +64 -0
  56. data/ext/couchbase/operations/document_get_and_touch.hxx +64 -0
  57. data/ext/couchbase/operations/document_increment.hxx +80 -0
  58. data/ext/couchbase/operations/document_insert.hxx +74 -0
  59. data/ext/couchbase/operations/{lookup_in.hxx → document_lookup_in.hxx} +2 -2
  60. data/ext/couchbase/operations/{mutate_in.hxx → document_mutate_in.hxx} +11 -2
  61. data/ext/couchbase/operations/{query.hxx → document_query.hxx} +101 -6
  62. data/ext/couchbase/operations/document_remove.hxx +67 -0
  63. data/ext/couchbase/operations/document_replace.hxx +76 -0
  64. data/ext/couchbase/operations/{upsert.hxx → document_touch.hxx} +14 -14
  65. data/ext/couchbase/operations/{remove.hxx → document_unlock.hxx} +12 -10
  66. data/ext/couchbase/operations/document_upsert.hxx +74 -0
  67. data/ext/couchbase/operations/query_index_build_deferred.hxx +85 -0
  68. data/ext/couchbase/operations/query_index_create.hxx +134 -0
  69. data/ext/couchbase/operations/query_index_drop.hxx +108 -0
  70. data/ext/couchbase/operations/query_index_get_all.hxx +106 -0
  71. data/ext/couchbase/operations/scope_create.hxx +81 -0
  72. data/ext/couchbase/operations/scope_drop.hxx +79 -0
  73. data/ext/couchbase/operations/scope_get_all.hxx +72 -0
  74. data/ext/couchbase/protocol/client_opcode.hxx +35 -0
  75. data/ext/couchbase/protocol/client_request.hxx +56 -9
  76. data/ext/couchbase/protocol/client_response.hxx +52 -15
  77. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +81 -0
  78. data/ext/couchbase/protocol/cmd_decrement.hxx +187 -0
  79. data/ext/couchbase/protocol/cmd_exists.hxx +171 -0
  80. data/ext/couchbase/protocol/cmd_get.hxx +31 -8
  81. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +142 -0
  82. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +142 -0
  83. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +16 -3
  84. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +16 -3
  85. data/ext/couchbase/protocol/cmd_get_error_map.hxx +16 -3
  86. data/ext/couchbase/protocol/cmd_hello.hxx +24 -8
  87. data/ext/couchbase/protocol/cmd_increment.hxx +187 -0
  88. data/ext/couchbase/protocol/cmd_info.hxx +1 -0
  89. data/ext/couchbase/protocol/cmd_insert.hxx +172 -0
  90. data/ext/couchbase/protocol/cmd_lookup_in.hxx +28 -13
  91. data/ext/couchbase/protocol/cmd_mutate_in.hxx +65 -13
  92. data/ext/couchbase/protocol/cmd_remove.hxx +59 -4
  93. data/ext/couchbase/protocol/cmd_replace.hxx +172 -0
  94. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +15 -3
  95. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +15 -3
  96. data/ext/couchbase/protocol/cmd_sasl_step.hxx +15 -3
  97. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -2
  98. data/ext/couchbase/protocol/cmd_touch.hxx +102 -0
  99. data/ext/couchbase/protocol/cmd_unlock.hxx +95 -0
  100. data/ext/couchbase/protocol/cmd_upsert.hxx +50 -14
  101. data/ext/couchbase/protocol/durability_level.hxx +67 -0
  102. data/ext/couchbase/protocol/frame_info_id.hxx +187 -0
  103. data/ext/couchbase/protocol/hello_feature.hxx +137 -0
  104. data/ext/couchbase/protocol/server_opcode.hxx +57 -0
  105. data/ext/couchbase/protocol/server_request.hxx +122 -0
  106. data/ext/couchbase/protocol/unsigned_leb128.h +15 -15
  107. data/ext/couchbase/utils/byteswap.hxx +1 -2
  108. data/ext/couchbase/utils/url_codec.hxx +225 -0
  109. data/ext/couchbase/version.hxx +3 -1
  110. data/ext/extconf.rb +4 -1
  111. data/ext/test/main.cxx +37 -113
  112. data/ext/third_party/snappy/.appveyor.yml +36 -0
  113. data/ext/third_party/snappy/.gitignore +8 -0
  114. data/ext/third_party/snappy/.travis.yml +98 -0
  115. data/ext/third_party/snappy/AUTHORS +1 -0
  116. data/ext/third_party/snappy/CMakeLists.txt +345 -0
  117. data/ext/third_party/snappy/CONTRIBUTING.md +26 -0
  118. data/ext/third_party/snappy/COPYING +54 -0
  119. data/ext/third_party/snappy/NEWS +188 -0
  120. data/ext/third_party/snappy/README.md +148 -0
  121. data/ext/third_party/snappy/cmake/SnappyConfig.cmake.in +33 -0
  122. data/ext/third_party/snappy/cmake/config.h.in +59 -0
  123. data/ext/third_party/snappy/docs/README.md +72 -0
  124. data/ext/third_party/snappy/format_description.txt +110 -0
  125. data/ext/third_party/snappy/framing_format.txt +135 -0
  126. data/ext/third_party/snappy/snappy-c.cc +90 -0
  127. data/ext/third_party/snappy/snappy-c.h +138 -0
  128. data/ext/third_party/snappy/snappy-internal.h +315 -0
  129. data/ext/third_party/snappy/snappy-sinksource.cc +121 -0
  130. data/ext/third_party/snappy/snappy-sinksource.h +182 -0
  131. data/ext/third_party/snappy/snappy-stubs-internal.cc +42 -0
  132. data/ext/third_party/snappy/snappy-stubs-internal.h +493 -0
  133. data/ext/third_party/snappy/snappy-stubs-public.h.in +63 -0
  134. data/ext/third_party/snappy/snappy-test.cc +613 -0
  135. data/ext/third_party/snappy/snappy-test.h +526 -0
  136. data/ext/third_party/snappy/snappy.cc +1770 -0
  137. data/ext/third_party/snappy/snappy.h +209 -0
  138. data/ext/third_party/snappy/snappy_compress_fuzzer.cc +60 -0
  139. data/ext/third_party/snappy/snappy_uncompress_fuzzer.cc +58 -0
  140. data/ext/third_party/snappy/snappy_unittest.cc +1512 -0
  141. data/ext/third_party/snappy/testdata/alice29.txt +3609 -0
  142. data/ext/third_party/snappy/testdata/asyoulik.txt +4122 -0
  143. data/ext/third_party/snappy/testdata/baddata1.snappy +0 -0
  144. data/ext/third_party/snappy/testdata/baddata2.snappy +0 -0
  145. data/ext/third_party/snappy/testdata/baddata3.snappy +0 -0
  146. data/ext/third_party/snappy/testdata/fireworks.jpeg +0 -0
  147. data/ext/third_party/snappy/testdata/geo.protodata +0 -0
  148. data/ext/third_party/snappy/testdata/html +1 -0
  149. data/ext/third_party/snappy/testdata/html_x_4 +1 -0
  150. data/ext/third_party/snappy/testdata/kppkn.gtb +0 -0
  151. data/ext/third_party/snappy/testdata/lcet10.txt +7519 -0
  152. data/ext/third_party/snappy/testdata/paper-100k.pdf +600 -2
  153. data/ext/third_party/snappy/testdata/plrabn12.txt +10699 -0
  154. data/ext/third_party/snappy/testdata/urls.10K +10000 -0
  155. data/lib/couchbase/binary_collection.rb +33 -76
  156. data/lib/couchbase/binary_collection_options.rb +94 -0
  157. data/lib/couchbase/bucket.rb +9 -3
  158. data/lib/couchbase/cluster.rb +161 -23
  159. data/lib/couchbase/collection.rb +108 -191
  160. data/lib/couchbase/collection_options.rb +430 -0
  161. data/lib/couchbase/errors.rb +136 -134
  162. data/lib/couchbase/json_transcoder.rb +32 -0
  163. data/lib/couchbase/management/analytics_index_manager.rb +185 -9
  164. data/lib/couchbase/management/bucket_manager.rb +84 -33
  165. data/lib/couchbase/management/collection_manager.rb +166 -1
  166. data/lib/couchbase/management/query_index_manager.rb +261 -0
  167. data/lib/couchbase/management/search_index_manager.rb +291 -0
  168. data/lib/couchbase/management/user_manager.rb +12 -10
  169. data/lib/couchbase/management/view_index_manager.rb +151 -1
  170. data/lib/couchbase/mutation_state.rb +11 -1
  171. data/lib/couchbase/scope.rb +4 -4
  172. data/lib/couchbase/version.rb +1 -1
  173. metadata +113 -18
  174. data/.travis.yml +0 -7
  175. data/ext/couchbase/io/binary_parser.hxx +0 -64
  176. data/lib/couchbase/results.rb +0 -307
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85cb801dc8f7b63d941b79865a732d57ed42bb120cb9e7aedeb5896fcdb9335a
4
- data.tar.gz: 83e988d0285aaf16389238afbbf0369aca85394712b8eb492f7f66646b5f4441
3
+ metadata.gz: cd8c352b8e6f1752e4a465be62889b7d00f89fa6dbb217ceb6a2fbcff601d4c2
4
+ data.tar.gz: 232734648d18dddac6acbc8f5ea1b3d40cec2efa1ef2e021e568b4491152cfcd
5
5
  SHA512:
6
- metadata.gz: 5bf2fe5ef893721de3a7e00ac26d731ed8d00ee47ab8fd2ba72097ae9218a4652618d4677d9899568de2c61d39082b5fdcd747b3f41e1a605abcf7756abc6540
7
- data.tar.gz: 654499d9954281e56a5fdcbb8e9c5162e2e97b51331603df37a3910d0595d335a8ea18c2057042c54f22faad9dad5e732860a4c591f05e8f119712bc6b6dd0e7
6
+ metadata.gz: ec3182ef85d573758801b9ed34ad034c441b247fe9aa52c23b8fead63671572ec338fa8c735c0194464d957d0eb0eddcc64aa4e300b83f40bb02a8a0dcf8d074
7
+ data.tar.gz: 35973818ce61c6b8a1d984125bcf5398940566d5f8f0d16b280fcdf7e2e5eea3c1dddf4cd2d9ee16b0ddff0d85933f683759996ed4feb6660f8279cf0213e19f
@@ -0,0 +1,49 @@
1
+ name: tests-6.0.3
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ services:
15
+ couchbase:
16
+ image: couchbase:enterprise-6.0.3
17
+ ports:
18
+ - 8091-8094:8091-8094
19
+ - 11210:11210
20
+
21
+ steps:
22
+ - name: Install build environment
23
+ run: sudo apt-get install -y libssl-dev cmake gcc g++ curl
24
+
25
+ - uses: actions/checkout@v2
26
+ with:
27
+ submodules: recursive
28
+
29
+ - name: Set up ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: 2.6
33
+
34
+ - name: Install dependencies
35
+ run: bundle install
36
+
37
+ - name: Initialize couchbase
38
+ run: ./bin/init-cluster
39
+
40
+ - name: Compile extension
41
+ run: bundle exec rake compile
42
+
43
+ - name: Display library version
44
+ run: bundle exec ruby -I lib -r couchbase -e 'pp Couchbase::VERSION'
45
+
46
+ - name: Run tests
47
+ run: bundle exec rake test
48
+ env:
49
+ TEST_SERVER_VERSION: 6.0.3
@@ -0,0 +1,47 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ services:
15
+ couchbase:
16
+ image: couchbase
17
+ ports:
18
+ - 8091-8094:8091-8094
19
+ - 11210:11210
20
+
21
+ steps:
22
+ - name: Install build environment
23
+ run: sudo apt-get install -y libssl-dev cmake gcc g++ curl
24
+
25
+ - uses: actions/checkout@v2
26
+ with:
27
+ submodules: recursive
28
+
29
+ - name: Set up ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: 2.6
33
+
34
+ - name: Install dependencies
35
+ run: bundle install
36
+
37
+ - name: Initialize couchbase
38
+ run: ./bin/init-cluster
39
+
40
+ - name: Compile extension
41
+ run: bundle exec rake compile
42
+
43
+ - name: Display library version
44
+ run: bundle exec ruby -I lib -r couchbase -e 'pp Couchbase::VERSION'
45
+
46
+ - name: Run tests
47
+ run: bundle exec rake test
@@ -13,3 +13,6 @@
13
13
  [submodule "ext/third_party/asio"]
14
14
  path = ext/third_party/asio
15
15
  url = git://github.com/chriskohlhoff/asio.git
16
+ [submodule "ext/third_party/snappy"]
17
+ path = ext/third_party/snappy
18
+ url = git://github.com/google/snappy.git
@@ -2,11 +2,16 @@
2
2
  <dictionary name="gem_terms">
3
3
  <words>
4
4
  <w>adhoc</w>
5
+ <w>datasets</w>
6
+ <w>datastores</w>
5
7
  <w>dataverse</w>
8
+ <w>keyspace</w>
6
9
  <w>libcouchbase</w>
7
10
  <w>opcode</w>
11
+ <w>subdoc</w>
8
12
  <w>subdocument</w>
9
13
  <w>upsert</w>
14
+ <w>upserting</w>
10
15
  <w>xattr</w>
11
16
  </words>
12
17
  </dictionary>
@@ -2,6 +2,7 @@
2
2
  <profile version="1.0">
3
3
  <option name="myName" value="Project Default" />
4
4
  <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
+ <inspection_tool class="RubyInstanceMethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
5
6
  <inspection_tool class="RubyStringKeysInHashInspection" enabled="false" level="WARNING" enabled_by_default="false" />
6
7
  </profile>
7
8
  </component>
@@ -6,6 +6,7 @@
6
6
  <mapping directory="$PROJECT_DIR$/ext/third_party/gsl" vcs="Git" />
7
7
  <mapping directory="$PROJECT_DIR$/ext/third_party/http_parser" vcs="Git" />
8
8
  <mapping directory="$PROJECT_DIR$/ext/third_party/json" vcs="Git" />
9
+ <mapping directory="$PROJECT_DIR$/ext/third_party/snappy" vcs="Git" />
9
10
  <mapping directory="$PROJECT_DIR$/ext/third_party/spdlog" vcs="Git" />
10
11
  </component>
11
12
  </project>
data/Gemfile CHANGED
@@ -19,5 +19,6 @@ gemspec
19
19
 
20
20
  group :development do
21
21
  gem "byebug"
22
+ gem "rake"
22
23
  # gem "sorbet"
23
24
  end
data/README.md CHANGED
@@ -1,6 +1,59 @@
1
- # Couchbase Ruby Client
1
+ # Couchbase Ruby Client [![tests](https://github.com/couchbase/couchbase-ruby-client/workflows/tests/badge.svg)](https://github.com/couchbase/couchbase-ruby-client/actions?query=workflow%3Atests)
2
2
 
3
- This repository contains the third generation of the Couchbase SDK for Ruby (aka. SDKv3)
3
+ This repository contains the third generation of the official Couchbase SDK for Ruby (aka. SDKv3)
4
+
5
+ ## Support and Feedback
6
+
7
+ If you find an issue, please file it in [our JIRA issue tracker](http://couchbase.com/issues/browse/RCBC).
8
+ Also you are always welcome on [our forum](https://forums.couchbase.com/c/ruby-sdk).
9
+
10
+ Please attach version information to ticket/post. To obtain this information use the following command:
11
+
12
+ $ ruby -r couchbase -e 'p Couchbase::VERSION'
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem "couchbase", "3.0.0.alpha.2"
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle install
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install --pre couchbase
29
+
30
+ For some platforms we precompile binary packages. When, for some reason, binary package cannot be used, pass
31
+ `--platform=ruby` to `gem install` command (or check `specific_platform` and `force_ruby_platform` options of Bundler).
32
+ In latter case, see [Development](#development) section for build dependencies.
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive
37
+ prompt that will allow you to experiment.
38
+
39
+ Part of the library is written in C++, and requires both C and C++ compilers installed on the system. To configure build
40
+ environment, it uses `cmake`. When these tools installed, the build process is easy:
41
+
42
+ $ rake compile
43
+
44
+ ## Generate Documentation
45
+
46
+ To generate documentation `yard` library is highly recommended.
47
+
48
+ $ gem install yard
49
+
50
+ The following steps will generate API reference for selected git tag:
51
+
52
+ $ rake doc
53
+
54
+ Now the API reference is accessible using web browser (where `VERSION` is current version of the SDK)
55
+
56
+ $ firefox doc/couchbase-ruby-client-VERSION/index.html
4
57
 
5
58
  ## License
6
59
 
data/Rakefile CHANGED
@@ -27,3 +27,21 @@ task :compile do
27
27
  sh "ruby #{File.join(__dir__, "ext", "extconf.rb")}"
28
28
  end
29
29
  end
30
+
31
+ task :doc do
32
+ require "couchbase/version"
33
+ input_dir = File.join(__dir__, "lib")
34
+ output_dir = File.join(__dir__, "doc", "couchbase-ruby-client-#{Couchbase::VERSION[:sdk]}")
35
+ rm_rf output_dir
36
+ sh "yard doc --output-dir #{output_dir} #{input_dir}"
37
+ puts "#{File.realpath(output_dir)}/index.html"
38
+ end
39
+
40
+ task :docs => :doc
41
+
42
+ task :render_git_revision do
43
+ build_version_path = File.join(__dir__, 'ext', 'build_version.hxx.in')
44
+ File.write(build_version_path, File.read(build_version_path).gsub('@BACKEND_GIT_REVISION@', `git rev-parse HEAD`.strip))
45
+ end
46
+
47
+ task :build => :render_git_revision
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Copyright 2020 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
+ HOST="localhost"
18
+ USERNAME="Administrator"
19
+ PASSWORD="password"
20
+ CREDS="${USERNAME}:${PASSWORD}"
21
+
22
+ sleep 1
23
+
24
+ set -ex
25
+
26
+ # Ping cluster
27
+ curl -sS http://${HOST}:8091/pools
28
+
29
+ # Initialize Node
30
+ curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/nodes/self/controller/settings \
31
+ -d 'path=%2Fopt%2Fcouchbase%2Fvar%2Flib%2Fcouchbase%2Fdata' \
32
+ -d 'index_path=%2Fopt%2Fcouchbase%2Fvar%2Flib%2Fcouchbase%2Fdata'
33
+
34
+ # Setup Services
35
+ curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/node/controller/setupServices \
36
+ -d 'services=kv%2Cn1ql%2Cindex'
37
+
38
+ # Setup Memory Quotas
39
+ curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/pools/default \
40
+ -d 'memoryQuota=256' \
41
+ -d 'indexMemoryQuota=256'
42
+
43
+ # Setup Administrator username and password
44
+ curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/settings/web \
45
+ -d "password=${PASSWORD}" \
46
+ -d "username=${USERNAME}" \
47
+ -d "port=SAME"
48
+
49
+ # Setup index settings
50
+ curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/settings/indexes \
51
+ -d "storageMode=plasma"
52
+
53
+ # Setup Bucket
54
+ curl -sS -w "\n" -u ${CREDS} http://${HOST}:8091/pools/default/buckets \
55
+ -d 'flushEnabled=1' \
56
+ -d 'threadsNumber=3' \
57
+ -d 'replicaIndex=0' \
58
+ -d 'replicaNumber=0' \
59
+ -d 'evictionPolicy=valueOnly' \
60
+ -d 'ramQuotaMB=100' \
61
+ -d 'bucketType=membase' \
62
+ -d 'name=default'
data/bin/setup CHANGED
@@ -19,5 +19,6 @@ PROJECT_ROOT="$( cd "$(dirname "$0"/..)" >/dev/null 2>&1 ; pwd -P )"
19
19
  set -euo pipefail
20
20
  IFS=$'\n\t'
21
21
  set -vx
22
+ git submodule update --init
22
23
  bundle config set --local path ${PROJECT_ROOT}/vendor/bundle
23
24
  bundle install
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.email = ["sergey.avseyev@gmail.com"]
24
24
  spec.summary = "SDK for Couchbase Server"
25
25
  spec.description = "Modern SDK for Couchbase Server"
26
- spec.homepage = "https://github.com/couchbase/couchbase.rb"
27
- spec.license = "MIT"
26
+ spec.homepage = "https://www.couchbase.com"
27
+ spec.license = "Apache-2.0"
28
28
 
29
29
  spec.metadata["homepage_uri"] = spec.homepage
30
30
  spec.metadata["source_code_uri"] = "https://github.com/couchbase/couchbase-ruby-client"
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
38
  spec.require_paths = ["lib"]
39
39
  spec.extensions = ["ext/extconf.rb"]
40
+ spec.rdoc_options.append('--exclude', 'ext/')
40
41
 
41
42
  spec.add_development_dependency "bundler", "~> 2.1"
42
43
  spec.add_development_dependency "rake", "~> 13.0"
@@ -1,4 +1,3 @@
1
- require 'irb'
2
1
  require 'couchbase'
3
2
  include Couchbase
4
3
 
@@ -12,7 +11,7 @@ res = collection.upsert("foo", {"bar" => 42})
12
11
  p res.cas
13
12
 
14
13
  res = collection.get("foo")
15
- p res.content_as :json
14
+ p res.content
16
15
  p res.cas
17
16
 
18
17
  res = collection.remove("foo")
@@ -0,0 +1,47 @@
1
+ require 'couchbase'
2
+ include Couchbase
3
+
4
+ def measure(msg)
5
+ start = Time.now
6
+ yield
7
+ printf "%s in %.2f seconds\n", msg, Time.now - start
8
+ end
9
+
10
+ options = Cluster::ClusterOptions.new
11
+ options.authenticate("Administrator", "password")
12
+ cluster = Cluster.connect("couchbase://localhost", options)
13
+
14
+ bucket_name = "new_bucket"
15
+
16
+ all_buckets = cluster.buckets.get_all_buckets
17
+ puts "There are #{all_buckets.size} buckets on the cluster"
18
+ all_buckets.each do |bucket|
19
+ puts " * #{bucket.name} (type: #{bucket.bucket_type}, quota: #{bucket.ram_quota_mb} MB)"
20
+ end
21
+
22
+ if all_buckets.any? { |bucket| bucket.name == bucket_name }
23
+ measure("Bucket #{bucket_name.inspect} removed") { cluster.buckets.drop_bucket(bucket_name) }
24
+ end
25
+
26
+ settings = Management::BucketSettings.new
27
+ settings.name = bucket_name
28
+ settings.ram_quota_mb = 100
29
+ settings.flush_enabled = true
30
+ measure("New bucket #{bucket_name.inspect} created") { cluster.buckets.create_bucket(settings) }
31
+
32
+ sleep(1)
33
+
34
+ settings = cluster.buckets.get_bucket(bucket_name)
35
+ puts "Bucket #{bucket_name.inspect} settings:"
36
+ puts " * healthy? : #{settings.healthy?}"
37
+ puts " * RAM quota : #{settings.ram_quota_mb}"
38
+ puts " * number of replicas : #{settings.num_replicas}"
39
+ puts " * flush enabled: : #{settings.flush_enabled}"
40
+ puts " * max TTL : #{settings.max_expiry}"
41
+ puts " * compression mode : #{settings.compression_mode}"
42
+ puts " * replica indexes : #{settings.replica_indexes}"
43
+ puts " * ejection policy : #{settings.ejection_policy}"
44
+
45
+ measure("Bucket #{bucket_name.inspect} flushed") { cluster.buckets.flush_bucket(bucket_name) }
46
+
47
+ cluster.disconnect
@@ -0,0 +1,58 @@
1
+ require 'couchbase'
2
+ include Couchbase
3
+
4
+ def measure(msg)
5
+ start = Time.now
6
+ yield
7
+ printf "%s in %.2f seconds\n", msg, Time.now - start
8
+ end
9
+
10
+ bucket_name = "travel-sample"
11
+ scope_name = "myapp"
12
+
13
+ options = Cluster::ClusterOptions.new
14
+ options.authenticate("Administrator", "password")
15
+ cluster = Cluster.connect("couchbase://localhost", options)
16
+ bucket = cluster.bucket(bucket_name)
17
+
18
+
19
+ scopes = bucket.collections.get_all_scopes
20
+ puts "There are #{scopes.size} on the bucket \"#{bucket_name}\""
21
+
22
+ scopes.each do |scope|
23
+ puts " * \"#{scope.name}\" (#{scope.collections.size})"
24
+ scope.collections.each do |collection|
25
+ puts " * \"#{collection.name}\""
26
+ end
27
+ end
28
+
29
+ if scopes.any? {|scope| scope.name == scope_name }
30
+ measure("Scope \"#{scope_name}\" has been removed") { bucket.collections.drop_scope(scope_name) }
31
+ end
32
+ measure("Scope \"#{scope_name}\" has been created") { bucket.collections.create_scope(scope_name) }
33
+
34
+ scope = bucket.collections.get_scope(scope_name)
35
+ puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
36
+
37
+ collection = Management::CollectionSpec.new
38
+ collection.scope_name = scope_name
39
+ collection.name = "users"
40
+ measure("Collection \"#{collection.name}\" on scope \"#{collection.scope_name}\" has been created") do
41
+ bucket.collections.create_collection(collection)
42
+ end
43
+
44
+ scope = bucket.collections.get_scope(scope_name)
45
+ puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
46
+ scope.collections.each do |collection|
47
+ puts " * \"#{collection.name}\""
48
+ end
49
+
50
+ measure("Collection \"#{collection.name}\" on scope \"#{collection.scope_name}\" has been dropped") do
51
+ bucket.collections.drop_collection(collection)
52
+ end
53
+
54
+ scope = bucket.collections.get_scope(scope_name)
55
+ puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
56
+ scope.collections.each do |collection|
57
+ puts " * \"#{collection.name}\""
58
+ end