couchbase-jruby-client 0.2.2-java → 1.0.4-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +103 -0
  3. data/.ruby-version +1 -1
  4. data/Rakefile +13 -2
  5. data/couchbase-jruby-client.gemspec +7 -6
  6. data/lib/couchbase/bucket.rb +11 -338
  7. data/lib/couchbase/cluster.rb +10 -88
  8. data/lib/couchbase/configuration.rb +39 -0
  9. data/lib/couchbase/design_doc.rb +18 -73
  10. data/lib/couchbase/document.rb +34 -0
  11. data/lib/couchbase/error.rb +0 -35
  12. data/lib/couchbase/operations.rb +60 -40
  13. data/lib/couchbase/version.rb +1 -1
  14. data/lib/couchbase/view.rb +55 -345
  15. data/lib/couchbase.rb +37 -141
  16. data/lib/jars/couchbase-core-io-1.1.4.jar +0 -0
  17. data/lib/jars/couchbase-java-client-2.1.4.jar +0 -0
  18. data/lib/jars/rxjava-1.0.8.jar +0 -0
  19. data/lib/jars/rxjruby-0.0.1.jar +0 -0
  20. data/test/{test_cas.rb → helper.rb} +15 -10
  21. data/test/test_bucket.rb +14 -228
  22. data/test/test_cluster.rb +1 -29
  23. data/test/test_configuration.rb +51 -0
  24. data/test/test_couchbase.rb +28 -28
  25. data/test/test_design_doc.rb +29 -0
  26. data/test/test_document.rb +51 -0
  27. data/test/test_operations.rb +49 -0
  28. data/test/test_view.rb +62 -116
  29. metadata +43 -125
  30. data/lib/couchbase/async/callback.rb +0 -38
  31. data/lib/couchbase/async/queue.rb +0 -26
  32. data/lib/couchbase/async.rb +0 -32
  33. data/lib/couchbase/constants.rb +0 -29
  34. data/lib/couchbase/operations/arithmetic.rb +0 -290
  35. data/lib/couchbase/operations/delete.rb +0 -115
  36. data/lib/couchbase/operations/design_docs.rb +0 -99
  37. data/lib/couchbase/operations/fetch.rb +0 -33
  38. data/lib/couchbase/operations/get.rb +0 -303
  39. data/lib/couchbase/operations/stats.rb +0 -42
  40. data/lib/couchbase/operations/store.rb +0 -463
  41. data/lib/couchbase/operations/touch.rb +0 -140
  42. data/lib/couchbase/operations/unlock.rb +0 -209
  43. data/lib/couchbase/operations/utils.rb +0 -68
  44. data/lib/couchbase/query.rb +0 -76
  45. data/lib/couchbase/result.rb +0 -60
  46. data/lib/couchbase/transcoder.rb +0 -81
  47. data/lib/couchbase/utils.rb +0 -62
  48. data/lib/couchbase/view_row.rb +0 -227
  49. data/lib/jars/commons-codec-1.5.jar +0 -0
  50. data/lib/jars/couchbase-client-1.3.2-javadoc.jar +0 -0
  51. data/lib/jars/couchbase-client-1.3.2-sources.jar +0 -0
  52. data/lib/jars/couchbase-client-1.3.2.jar +0 -0
  53. data/lib/jars/httpcore-4.3.1.jar +0 -0
  54. data/lib/jars/httpcore-nio-4.3.1.jar +0 -0
  55. data/lib/jars/jettison-1.1.jar +0 -0
  56. data/lib/jars/netty-3.5.5.Final.jar +0 -0
  57. data/lib/jars/spymemcached-2.10.5-javadoc.jar +0 -0
  58. data/lib/jars/spymemcached-2.10.5-sources.jar +0 -0
  59. data/lib/jars/spymemcached-2.10.5.jar +0 -0
  60. data/tasks/benchmark.rake +0 -6
  61. data/tasks/test.rake +0 -36
  62. data/tasks/util.rake +0 -21
  63. data/test/mock.rb +0 -85
  64. data/test/profile/.gitignore +0 -1
  65. data/test/profile/.jrubyrc +0 -722
  66. data/test/profile/Gemfile +0 -7
  67. data/test/profile/benchmark.rb +0 -177
  68. data/test/profile/profile.rb +0 -59
  69. data/test/setup.rb +0 -74
  70. data/test/test_arithmetic.rb +0 -155
  71. data/test/test_async.rb +0 -24
  72. data/test/test_couchbase_rails_cache_store.rb +0 -341
  73. data/test/test_delete.rb +0 -139
  74. data/test/test_design_docs.rb +0 -67
  75. data/test/test_errors.rb +0 -74
  76. data/test/test_fetch.rb +0 -71
  77. data/test/test_format.rb +0 -142
  78. data/test/test_get.rb +0 -363
  79. data/test/test_query.rb +0 -23
  80. data/test/test_result.rb +0 -15
  81. data/test/test_stats.rb +0 -44
  82. data/test/test_store.rb +0 -203
  83. data/test/test_touch.rb +0 -90
  84. data/test/test_unlock.rb +0 -89
  85. data/test/test_utils.rb +0 -67
  86. data/test/test_version.rb +0 -28
  87. data/test/test_view_row.rb +0 -74
data/test/test_view.rb CHANGED
@@ -1,140 +1,86 @@
1
- # Author:: Mike Evans <mike@urlgonomics.com>
2
- # Copyright:: 2013 Urlgonomics LLC.
3
- # License:: Apache License, Version 2.0
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
- require File.join(File.dirname(__FILE__), 'setup')
1
+ require 'helper'
19
2
 
20
3
  class TestView < Minitest::Test
21
4
 
22
5
  def setup
23
- return unless $mock.real?
24
-
25
- cb.save_design_doc(design_doc)
26
- { bob: 32, frank: 25, sam: 42, fred: 21 }.each_pair do |name, age|
27
- cb.set(name, { type: 'user', name: name, age: age })
28
- end
6
+ @bucket = Couchbase.bucket
7
+ @design_doc = {
8
+ test_map: {
9
+ map: <<-JS
10
+ function(doc, meta) {
11
+ emit(meta.id);
12
+ }
13
+ JS
14
+ },
15
+ test_reduce: {
16
+ map: 'function(doc, meta) { emit(meta.id, null); }',
17
+ reduce: '_count'
18
+ }
19
+ }
20
+ @bucket.save_design_doc('test', @design_doc)
29
21
  end
30
22
 
31
- def view
32
- @view ||= Couchbase::View.new(cb, '_design/users/_view/by_age')
33
- end
23
+ def test_view_query
24
+ @bucket.upsert(uniq_id, true)
25
+ results = @bucket.query('test', 'test_map')
26
+ .fresh
27
+ .fetch
34
28
 
35
- def reduce_view
36
- @reduce_view ||= Couchbase::View.new(cb, '_design/users/_view/all')
29
+ assert_equal true, results[uniq_id].data
37
30
  end
38
31
 
39
- def test_initialize
40
- skip unless $mock.real?
41
- assert_equal 'users', view.design_doc
42
- assert_equal 'by_age', view.name
43
- end
32
+ def test_key
33
+ @bucket.upsert(uniq_id, true)
34
+ results = @bucket.query('test', 'test_map')
35
+ .key(uniq_id)
36
+ .fresh
37
+ .fetch
44
38
 
45
- def test_simple_fetch
46
- skip unless $mock.real?
47
- assert results = view.fetch
48
- assert results.is_a?(Couchbase::View::ArrayWithTotalRows)
39
+ assert_equal 1, results.size
40
+ assert_equal true, results[uniq_id].data
49
41
  end
50
42
 
51
- def test_fetch_without_stale
52
- skip unless $mock.real?
53
- assert results = view.fetch(stale: false)
54
- assert_instance_of Couchbase::ViewRow, results.first
55
- assert results.first.doc.nil?
56
- assert_equal 4, results.total_rows
57
- results.each do |result|
58
- %w(bob frank sam fred).include?(result.id)
59
- %w(bob frank sam fred).include?(result.key)
60
- end
43
+ def test_keys
44
+ @bucket.upsert(uniq_id(:a), true)
45
+ @bucket.upsert(uniq_id(:b), true)
46
+ results = @bucket.query('test', 'test_map')
47
+ .keys([uniq_id(:a), uniq_id(:b)])
48
+ .fresh
49
+ .fetch
50
+
51
+ assert_equal 2, results.size
52
+ assert_equal true, results[uniq_id(:a)].data
53
+ assert_equal true, results[uniq_id(:b)].data
61
54
  end
62
55
 
63
- def test_fetch_no_docs
64
- skip unless $mock.real?
65
- assert results = view.fetch(include_docs: false, stale: false)
66
- assert_instance_of Couchbase::ViewRow, results.first
67
- assert results.first.doc.nil?
68
- assert_equal 4, results.total_rows
69
- results.each do |result|
70
- %w(bob frank sam fred).include?(result.id)
71
- %w(bob frank sam fred).include?(result.key)
72
- end
56
+ def test_returns_nils_as_appropriate
57
+ 100.times { |i| @bucket.upsert(uniq_id(i), true) }
58
+ # Force an index
59
+ @bucket.query('test', 'test_map').fresh.fetch
60
+ 100.times { |i| @bucket.remove(uniq_id(i)) }
61
+ results = @bucket.query('test', 'test_map').fetch
62
+ assert_nil results[uniq_id(23)]
73
63
  end
74
64
 
75
- def test_fetch_with_docs
76
- skip unless $mock.real?
77
- assert results = view.fetch(stale: false, include_docs: true)
78
- assert_instance_of Couchbase::View::ArrayWithTotalRows, results
79
- assert_instance_of Hash, results.first.doc
80
- end
65
+ def test_reduced_view
66
+ @bucket.upsert(uniq_id, true)
67
+ results = @bucket.query('test', 'test_reduce')
68
+ .fresh
69
+ .fetch
81
70
 
82
- def test_fetch_with_block
83
- skip unless $mock.real?
84
- refute view.fetch(stale: false, include_docs: true) { |row|
85
- assert_instance_of Couchbase::ViewRow, row
86
- assert row.doc['name'].is_a?(String)
87
- assert row.doc['age'].is_a?(Fixnum)
88
- }
71
+ assert_instance_of Fixnum, results
72
+ assert results > 0
89
73
  end
90
74
 
91
- def test_fetch_reduce
92
- skip unless $mock.real?
93
- assert results = reduce_view.fetch(stale: false, include_docs: false)
94
- assert_equal '4', results.first
95
- end
75
+ def test_non_reduced_view
76
+ @bucket.upsert(uniq_id, true)
77
+ results = @bucket.query('test', 'test_reduce')
78
+ .fresh
79
+ .reduce(false)
80
+ .fetch
96
81
 
97
- def test_fetch_without_reduce
98
- skip unless $mock.real?
99
- assert results = reduce_view.fetch(stale: false, reduce: false)
100
- assert_instance_of Couchbase::ViewRow, results.first
101
- assert results.first.doc.nil?
102
- assert_equal 4, results.total_rows
103
- results.each do |result|
104
- %w(bob frank sam fred).include?(result.key)
105
- end
82
+ assert_equal true, results[uniq_id].data
106
83
  end
107
84
 
108
- def test_design_doc_access
109
- skip unless $mock.real?
110
- view.fetch(stale: false, include_docs: true)
111
- assert results = cb.design_docs['users'].by_age.to_a
112
- assert_instance_of Couchbase::ViewRow, results.first
113
- end
114
85
 
115
- def design_doc
116
- {
117
- '_id' => '_design/users',
118
- 'language' => 'javascript',
119
- 'views' => {
120
- 'by_age' => {
121
- 'map' => <<-JS
122
- function (doc, meta) {
123
- if (doc.type && doc.type == 'user')
124
- emit(meta.id, doc.age);
125
- }
126
- JS
127
- },
128
- 'all' => {
129
- 'reduce' => '_count',
130
- 'map' => <<-JS
131
- function (doc, meta) {
132
- if (doc.type && doc.type == 'user')
133
- emit(meta.id, null);
134
- }
135
- JS
136
- }
137
- }
138
- }
139
- end
140
86
  end
metadata CHANGED
@@ -1,127 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase-jruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.4
5
5
  platform: java
6
6
  authors:
7
7
  - Mike Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: multi_json
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
16
  - - '>='
23
17
  - !ruby/object:Gem::Version
24
- version: '1.0'
18
+ version: '0'
19
+ name: multi_json
25
20
  prerelease: false
26
21
  type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: thread_safe
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
24
  - - '>='
32
25
  - !ruby/object:Gem::Version
33
- version: 0.1.2
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
30
  - - '>='
37
31
  - !ruby/object:Gem::Version
38
- version: 0.1.2
39
- prerelease: false
40
- type: :runtime
41
- - !ruby/object:Gem::Dependency
32
+ version: '0'
42
33
  name: bundler
34
+ prerelease: false
35
+ type: :development
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
38
  - - '>='
46
39
  - !ruby/object:Gem::Version
47
- version: '1.3'
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
48
42
  requirement: !ruby/object:Gem::Requirement
49
43
  requirements:
50
44
  - - '>='
51
45
  - !ruby/object:Gem::Version
52
- version: '1.3'
46
+ version: '0'
47
+ name: rake
53
48
  prerelease: false
54
49
  type: :development
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
50
  version_requirements: !ruby/object:Gem::Requirement
58
51
  requirements:
59
52
  - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
62
56
  requirement: !ruby/object:Gem::Requirement
63
57
  requirements:
64
58
  - - '>='
65
59
  - !ruby/object:Gem::Version
66
60
  version: '0'
61
+ name: minitest
67
62
  prerelease: false
68
63
  type: :development
69
- - !ruby/object:Gem::Dependency
70
- name: minitest
71
64
  version_requirements: !ruby/object:Gem::Requirement
72
65
  requirements:
73
66
  - - '>='
74
67
  - !ruby/object:Gem::Version
75
- version: 5.1.0
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
76
70
  requirement: !ruby/object:Gem::Requirement
77
71
  requirements:
78
72
  - - '>='
79
73
  - !ruby/object:Gem::Version
80
- version: 5.1.0
74
+ version: '0'
75
+ name: jrjackson
81
76
  prerelease: false
82
77
  type: :development
83
- - !ruby/object:Gem::Dependency
84
- name: jrjackson
85
78
  version_requirements: !ruby/object:Gem::Requirement
86
79
  requirements:
87
80
  - - '>='
88
81
  - !ruby/object:Gem::Version
89
- version: 0.2.3
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
90
84
  requirement: !ruby/object:Gem::Requirement
91
85
  requirements:
92
86
  - - '>='
93
87
  - !ruby/object:Gem::Version
94
- version: 0.2.3
88
+ version: '0'
89
+ name: pry
95
90
  prerelease: false
96
91
  type: :development
97
- - !ruby/object:Gem::Dependency
98
- name: pry
99
92
  version_requirements: !ruby/object:Gem::Requirement
100
93
  requirements:
101
94
  - - '>='
102
95
  - !ruby/object:Gem::Version
103
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
104
98
  requirement: !ruby/object:Gem::Requirement
105
99
  requirements:
106
100
  - - '>='
107
101
  - !ruby/object:Gem::Version
108
102
  version: '0'
103
+ name: rubocop
109
104
  prerelease: false
110
105
  type: :development
111
- - !ruby/object:Gem::Dependency
112
- name: mocha
113
106
  version_requirements: !ruby/object:Gem::Requirement
114
107
  requirements:
115
108
  - - '>='
116
109
  - !ruby/object:Gem::Version
117
110
  version: '0'
118
- requirement: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - '>='
121
- - !ruby/object:Gem::Version
122
- version: '0'
123
- prerelease: false
124
- type: :development
125
111
  description: Couchbase JRuby driver
126
112
  email:
127
113
  - mike@urlgonomics.com
@@ -131,6 +117,7 @@ extra_rdoc_files: []
131
117
  files:
132
118
  - .gitignore
133
119
  - .jrubyrc
120
+ - .rubocop.yml
134
121
  - .ruby-version
135
122
  - .travis.yml
136
123
  - Gemfile
@@ -139,76 +126,28 @@ files:
139
126
  - Rakefile
140
127
  - couchbase-jruby-client.gemspec
141
128
  - lib/couchbase.rb
142
- - lib/couchbase/async.rb
143
- - lib/couchbase/async/callback.rb
144
- - lib/couchbase/async/queue.rb
145
129
  - lib/couchbase/bucket.rb
146
130
  - lib/couchbase/cluster.rb
147
- - lib/couchbase/constants.rb
131
+ - lib/couchbase/configuration.rb
148
132
  - lib/couchbase/design_doc.rb
133
+ - lib/couchbase/document.rb
149
134
  - lib/couchbase/error.rb
150
135
  - lib/couchbase/operations.rb
151
- - lib/couchbase/operations/arithmetic.rb
152
- - lib/couchbase/operations/delete.rb
153
- - lib/couchbase/operations/design_docs.rb
154
- - lib/couchbase/operations/fetch.rb
155
- - lib/couchbase/operations/get.rb
156
- - lib/couchbase/operations/stats.rb
157
- - lib/couchbase/operations/store.rb
158
- - lib/couchbase/operations/touch.rb
159
- - lib/couchbase/operations/unlock.rb
160
- - lib/couchbase/operations/utils.rb
161
- - lib/couchbase/query.rb
162
- - lib/couchbase/result.rb
163
- - lib/couchbase/transcoder.rb
164
- - lib/couchbase/utils.rb
165
136
  - lib/couchbase/version.rb
166
137
  - lib/couchbase/view.rb
167
- - lib/couchbase/view_row.rb
168
- - lib/jars/commons-codec-1.5.jar
169
- - lib/jars/couchbase-client-1.3.2-javadoc.jar
170
- - lib/jars/couchbase-client-1.3.2-sources.jar
171
- - lib/jars/couchbase-client-1.3.2.jar
172
- - lib/jars/httpcore-4.3.1.jar
173
- - lib/jars/httpcore-nio-4.3.1.jar
174
- - lib/jars/jettison-1.1.jar
175
- - lib/jars/netty-3.5.5.Final.jar
176
- - lib/jars/spymemcached-2.10.5-javadoc.jar
177
- - lib/jars/spymemcached-2.10.5-sources.jar
178
- - lib/jars/spymemcached-2.10.5.jar
179
- - tasks/benchmark.rake
180
- - tasks/test.rake
181
- - tasks/util.rake
182
- - test/mock.rb
183
- - test/profile/.gitignore
184
- - test/profile/.jrubyrc
185
- - test/profile/Gemfile
186
- - test/profile/benchmark.rb
187
- - test/profile/profile.rb
188
- - test/setup.rb
189
- - test/test_arithmetic.rb
190
- - test/test_async.rb
138
+ - lib/jars/couchbase-core-io-1.1.4.jar
139
+ - lib/jars/couchbase-java-client-2.1.4.jar
140
+ - lib/jars/rxjava-1.0.8.jar
141
+ - lib/jars/rxjruby-0.0.1.jar
142
+ - test/helper.rb
191
143
  - test/test_bucket.rb
192
- - test/test_cas.rb
193
144
  - test/test_cluster.rb
145
+ - test/test_configuration.rb
194
146
  - test/test_couchbase.rb
195
- - test/test_couchbase_rails_cache_store.rb
196
- - test/test_delete.rb
197
- - test/test_design_docs.rb
198
- - test/test_errors.rb
199
- - test/test_fetch.rb
200
- - test/test_format.rb
201
- - test/test_get.rb
202
- - test/test_query.rb
203
- - test/test_result.rb
204
- - test/test_stats.rb
205
- - test/test_store.rb
206
- - test/test_touch.rb
207
- - test/test_unlock.rb
208
- - test/test_utils.rb
209
- - test/test_version.rb
147
+ - test/test_design_doc.rb
148
+ - test/test_document.rb
149
+ - test/test_operations.rb
210
150
  - test/test_view.rb
211
- - test/test_view_row.rb
212
151
  homepage: https://github.com/mje113/couchbase-jruby-client
213
152
  licenses:
214
153
  - Apache
@@ -229,38 +168,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
168
  version: '0'
230
169
  requirements: []
231
170
  rubyforge_project:
232
- rubygems_version: 2.1.9
171
+ rubygems_version: 2.4.8
233
172
  signing_key:
234
173
  specification_version: 4
235
174
  summary: The unofficial jruby client library for use with Couchbase Server.
236
175
  test_files:
237
- - test/mock.rb
238
- - test/profile/.gitignore
239
- - test/profile/.jrubyrc
240
- - test/profile/Gemfile
241
- - test/profile/benchmark.rb
242
- - test/profile/profile.rb
243
- - test/setup.rb
244
- - test/test_arithmetic.rb
245
- - test/test_async.rb
176
+ - test/helper.rb
246
177
  - test/test_bucket.rb
247
- - test/test_cas.rb
248
178
  - test/test_cluster.rb
179
+ - test/test_configuration.rb
249
180
  - test/test_couchbase.rb
250
- - test/test_couchbase_rails_cache_store.rb
251
- - test/test_delete.rb
252
- - test/test_design_docs.rb
253
- - test/test_errors.rb
254
- - test/test_fetch.rb
255
- - test/test_format.rb
256
- - test/test_get.rb
257
- - test/test_query.rb
258
- - test/test_result.rb
259
- - test/test_stats.rb
260
- - test/test_store.rb
261
- - test/test_touch.rb
262
- - test/test_unlock.rb
263
- - test/test_utils.rb
264
- - test/test_version.rb
181
+ - test/test_design_doc.rb
182
+ - test/test_document.rb
183
+ - test/test_operations.rb
265
184
  - test/test_view.rb
266
- - test/test_view_row.rb
@@ -1,38 +0,0 @@
1
- # Author:: Mike Evans <mike@urlgonomics.com>
2
- # Copyright:: 2013 Urlgonomics LLC.
3
- # License:: Apache License, Version 2.0
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
- module Couchbase
19
- module Async
20
- class Callback
21
- include Java::NetSpyMemcachedInternal::OperationCompletionListener
22
- include Java::NetSpyMemcachedInternal::GetCompletionListener
23
-
24
- def initialize(params, &callback)
25
- @params = params
26
- @callback = callback
27
- end
28
-
29
- def onComplete(future)
30
- result = Couchbase::Result.new(@params.merge(future: future))
31
- @callback.call(result)
32
- rescue Exception => e
33
- result.error = e
34
- return result
35
- end
36
- end
37
- end
38
- end
@@ -1,26 +0,0 @@
1
- module Couchbase
2
- module Async
3
- class Queue
4
-
5
- def initialize(bucket)
6
- @bucket = bucket
7
- @futures = []
8
- end
9
-
10
- def add_future(future, options, &block)
11
- @futures << [ future, options, block ]
12
- end
13
-
14
- def join
15
- while future = @futures.pop
16
- begin
17
- future, options, callback = future
18
- future.get
19
- result = Couchbase::Result.new({ bucket: @bucket, future: future }.merge(options))
20
- callback.call(result) unless callback.nil?
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,32 +0,0 @@
1
- # Author:: Mike Evans <mike@urlgonomics.com>
2
- # Copyright:: 2013 Urlgonomics LLC.
3
- # License:: Apache License, Version 2.0
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
- require 'couchbase/async/callback'
19
- require 'couchbase/async/queue'
20
-
21
- module Couchbase
22
- module Async
23
-
24
- private
25
-
26
- def register_future(future, params, &block)
27
- callback = Callback.new(params, &block)
28
- future.addListener(callback)
29
- future
30
- end
31
- end
32
- end
@@ -1,29 +0,0 @@
1
- # Author:: Couchbase <info@couchbase.com>
2
- # Copyright:: 2011, 2012 Couchbase, Inc.
3
- # License:: Apache License, Version 2.0
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
- module Couchbase
19
- module Constants # :nodoc:
20
- S_ID = 'id'.freeze
21
- S_DOC = 'doc'.freeze
22
- S_VALUE = 'value'.freeze
23
- S_META = 'meta'.freeze
24
- S_FLAGS = 'flags'.freeze
25
- S_CAS = 'cas'.freeze
26
- S_KEY = 'key'.freeze
27
- S_IS_LAST = Object.new.freeze
28
- end
29
- end