couchbase 1.2.0.z.beta-x86-mingw32 → 1.2.1-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/.travis.yml +1 -1
  2. data/Makefile +3 -0
  3. data/README.markdown +15 -4
  4. data/RELEASE_NOTES.markdown +526 -0
  5. data/couchbase.gemspec +0 -1
  6. data/ext/couchbase_ext/arguments.c +161 -244
  7. data/ext/couchbase_ext/arithmetic.c +29 -37
  8. data/ext/couchbase_ext/bucket.c +252 -219
  9. data/ext/couchbase_ext/couchbase_ext.c +540 -417
  10. data/ext/couchbase_ext/couchbase_ext.h +218 -191
  11. data/ext/couchbase_ext/delete.c +30 -27
  12. data/ext/couchbase_ext/extconf.rb +15 -3
  13. data/ext/couchbase_ext/get.c +45 -37
  14. data/ext/couchbase_ext/http.c +95 -74
  15. data/ext/couchbase_ext/multithread_plugin.c +1238 -0
  16. data/ext/couchbase_ext/observe.c +42 -37
  17. data/ext/couchbase_ext/result.c +17 -20
  18. data/ext/couchbase_ext/stats.c +30 -28
  19. data/ext/couchbase_ext/store.c +47 -39
  20. data/ext/couchbase_ext/timer.c +11 -11
  21. data/ext/couchbase_ext/touch.c +30 -27
  22. data/ext/couchbase_ext/unlock.c +30 -27
  23. data/ext/couchbase_ext/utils.c +166 -89
  24. data/ext/couchbase_ext/version.c +29 -26
  25. data/lib/action_dispatch/middleware/session/couchbase_store.rb +2 -2
  26. data/lib/active_support/cache/couchbase_store.rb +6 -6
  27. data/lib/couchbase.rb +1 -0
  28. data/lib/couchbase/bucket.rb +6 -11
  29. data/lib/couchbase/cluster.rb +105 -0
  30. data/lib/couchbase/utils.rb +8 -5
  31. data/lib/couchbase/version.rb +1 -1
  32. data/lib/couchbase/view.rb +51 -5
  33. data/lib/couchbase/view_row.rb +1 -1
  34. data/lib/ext/multi_json_fix.rb +13 -9
  35. data/lib/rack/session/couchbase.rb +11 -7
  36. data/tasks/compile.rake +1 -1
  37. data/tasks/test.rake +40 -34
  38. data/tasks/util.rake +1 -1
  39. data/test/setup.rb +9 -2
  40. data/test/test_arithmetic.rb +37 -0
  41. data/test/test_async.rb +22 -18
  42. data/test/test_unlock.rb +0 -1
  43. data/test/test_utils.rb +32 -0
  44. metadata +13 -23
  45. data/HISTORY.markdown +0 -219
@@ -115,7 +115,7 @@ module Couchbase
115
115
  @value = data['value']
116
116
  if data['doc']
117
117
  @meta = data['doc']['meta']
118
- @doc = data['doc']['json']
118
+ @doc = data['doc']['value']
119
119
  end
120
120
  @id = data['id'] || @meta && @meta['id']
121
121
  @views = []
@@ -24,10 +24,23 @@ if MultiJson.respond_to?(:engine)
24
24
  else
25
25
  multi_json_engine = MultiJson.send(:adapter)
26
26
  end
27
+
28
+ # Patch for MultiJson versions < 1.3.3
29
+ require 'multi_json/version'
30
+ if Gem::Version.new(MultiJson::VERSION) < Gem::Version.new('1.3.3')
31
+ class << MultiJson
32
+ alias :dump :encode
33
+ alias :load :decode
34
+ end
35
+ end
36
+
27
37
  if multi_json_engine.name =~ /JsonGem$/
28
38
  class << multi_json_engine
29
39
  alias _load_object load
30
40
  def load(string, options = {})
41
+ if string.is_a?(StringIO)
42
+ string = string.read
43
+ end
31
44
  if string =~ /\A\s*[{\[]/
32
45
  _load_object(string, options)
33
46
  else
@@ -36,12 +49,3 @@ if multi_json_engine.name =~ /JsonGem$/
36
49
  end
37
50
  end
38
51
  end
39
-
40
- # Patch for MultiJson versions < 1.3.3
41
- if MultiJson.respond_to?(:decode) && MultiJson.respond_to?(:encode) &&
42
- !MultiJson.respond_to?(:load) && !MultiJson.respond_to?(:dump)
43
- class << MultiJson
44
- alias :dump :encode
45
- alias :load :decode
46
- end
47
- end
@@ -33,16 +33,20 @@ module Rack
33
33
  #
34
34
  # require 'rack/session/couchbase'
35
35
  # use Rack::Session::Couchbase, :expire_after => 5.minutes,
36
- # :couchbase => {:bucket => "sessions", :default_format => :marshal}
36
+ # :couchbase => {:bucket => "sessions", :default_format => :document}
37
37
  #
38
- # By default sessions will be serialized to JSON, to allow analyse them
39
- # using Map/Reduce.
38
+ # By default sessions will be serialized using Marshal class. But
39
+ # you can store them as JSON (+:default_format => :document+), to
40
+ # allow analyse them using Map/Reduce. In this case you should
41
+ # care about serialization of all custom objects like
42
+ # ActionDispatch::Flash::FlashHash
40
43
  #
41
44
  class Couchbase < Abstract::ID
42
45
  attr_reader :mutex, :pool
43
46
 
44
47
  DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge(
45
- :couchbase => {:default_format => :document, :key_prefix => 'rack:session:'})
48
+ :couchbase => {:quiet => true, :default_format => :marshal,
49
+ :key_prefix => 'rack:session:'})
46
50
 
47
51
  def initialize(app, options = {})
48
52
  # Support old :expires option
@@ -57,7 +61,7 @@ module Rack
57
61
  end
58
62
 
59
63
  def generate_sid
60
- loop do
64
+ while true
61
65
  sid = super
62
66
  break sid unless @pool.get(sid)
63
67
  end
@@ -75,7 +79,7 @@ module Rack
75
79
 
76
80
  def set_session(env, session_id, new_session, options)
77
81
  with_lock(env, false) do
78
- @pool.set session_id, new_session, options
82
+ @pool.set(session_id, new_session, options)
79
83
  session_id
80
84
  end
81
85
  end
@@ -90,7 +94,7 @@ module Rack
90
94
  def with_lock(env, default = nil)
91
95
  @mutex.lock if env['rack.multithread']
92
96
  yield
93
- rescue Couchbase::Error::Connect, Couchbase::Error::Timeout
97
+ rescue ::Couchbase::Error::Connect, ::Couchbase::Error::Timeout
94
98
  if $VERBOSE
95
99
  warn "#{self} is unable to find Couchbase server."
96
100
  warn $!.inspect
data/tasks/compile.rake CHANGED
@@ -84,7 +84,7 @@ namespace :ports do
84
84
  directory "ports"
85
85
 
86
86
  task :libcouchbase => ["ports"] do
87
- recipe = MiniPortile.new "libcouchbase", "2.0.0beta_5_g970a292"
87
+ recipe = MiniPortile.new "libcouchbase", "2.0.1"
88
88
  recipe.files << "http://packages.couchbase.com/clients/c/libcouchbase-#{recipe.version}.tar.gz"
89
89
  recipe.configure_options.push("--disable-debug",
90
90
  "--disable-dependency-tracking",
data/tasks/test.rake CHANGED
@@ -41,54 +41,60 @@ end
41
41
 
42
42
  Rake::TestTask.new do |test|
43
43
  test.libs << "test" << "."
44
- test.ruby_opts << "-rruby-debug" if ENV['DEBUG']
45
44
  test.pattern = 'test/test_*.rb'
46
45
  test.options = '--verbose'
47
46
  end
48
47
 
49
48
  Rake::Task['test'].prerequisites.unshift('test/CouchbaseMock.jar')
50
49
 
51
- desc "Run the test suite under Valgrind."
50
+ common_flags = %w[
51
+ --tool=memcheck
52
+ --error-limit=no
53
+ --undef-value-errors=no
54
+ --leak-check=full
55
+ --show-reachable=yes
56
+ --num-callers=50
57
+ --track-fds=yes
58
+ --workaround-gcc296-bugs=yes
59
+ --leak-resolution=med
60
+ --max-stackframe=7304328
61
+ --partial-loads-ok=yes
62
+ ]
63
+
64
+ desc "Run the test suite under Valgrind memcheck."
52
65
  task "test:valgrind" do
53
- ENV['RUBY_PREFIX'] = [
54
- "valgrind",
55
- "--num-callers=50",
56
- "--error-limit=no",
57
- "--partial-loads-ok=yes",
58
- "--undef-value-errors=no",
59
- "--track-fds=yes",
60
- "--leak-check=full",
61
- "--leak-resolution=med",
62
- ].join(' ')
66
+ ENV['RUBY_PREFIX'] = "valgrind #{common_flags.join(' ')}"
63
67
  Rake::Task['test'].invoke
64
68
  end
65
69
 
66
- desc "Run the test suite under Valgrind with memory-fill."
70
+ desc "Run the test suite under Valgrind memcheck with memory-fill."
67
71
  task "test:valgrind:mem_fill" do
68
- ENV['RUBY_PREFIX'] = [
69
- "valgrind",
70
- "--num-callers=50",
71
- "--error-limit=no",
72
- "--partial-loads-ok=yes",
73
- "--undef-value-errors=no",
74
- "--freelist-vol=100000000",
75
- "--malloc-fill=6D",
76
- "--free-fill=66",
77
- ].join(' ')
72
+ local_flags = %w[
73
+ --malloc-fill=6D
74
+ --freelist-vol=100000000
75
+ --free-fill=66
76
+ ]
77
+ ENV['RUBY_PREFIX'] = "valgrind #{common_flags.join(' ')} #{local_flags.join(' ')}"
78
78
  Rake::Task['test'].invoke
79
79
  end
80
80
 
81
- desc "Run the test suite under Valgrind with memory-zero."
81
+ desc "Run the test suite under Valgrind memcheck with memory-zero."
82
82
  task "test:valgrind:mem_zero" do
83
- ENV['RUBY_PREFIX'] = [
84
- "valgrind",
85
- "--num-callers=50",
86
- "--error-limit=no",
87
- "--partial-loads-ok=yes",
88
- "--undef-value-errors=no",
89
- "--freelist-vol=100000000",
90
- "--malloc-fill=00",
91
- "--free-fill=00",
92
- ].join(' ')
83
+ local_flags = %w[
84
+ --freelist-vol=100000000
85
+ --malloc-fill=00
86
+ --free-fill=00
87
+ ]
88
+ ENV['RUBY_PREFIX'] = "valgrind #{common_flags.join(' ')} #{local_flags.join(' ')}"
89
+ Rake::Task['test'].invoke
90
+ end
91
+
92
+ desc "Run the test suite under Valgrind massif."
93
+ task "test:valgrind:massif" do
94
+ local_flags = %w[
95
+ --tool=massif
96
+ --time-unit=B
97
+ ]
98
+ ENV['RUBY_PREFIX'] = "valgrind #{local_flags.join(' ')}"
93
99
  Rake::Task['test'].invoke
94
100
  end
data/tasks/util.rake CHANGED
@@ -17,5 +17,5 @@
17
17
 
18
18
  desc 'Start an irb session and load the library.'
19
19
  task :console => :compile do
20
- exec "irb -I lib -r#{RUBY_VERSION =~ /^1\.9/ ? 'debugger' : 'ruby-debug'} -rcouchbase"
20
+ exec "irb -I lib -rcouchbase"
21
21
  end
data/test/setup.rb CHANGED
@@ -55,7 +55,7 @@ class CouchbaseServer
55
55
  rescue Couchbase::Error::NotSupported
56
56
  # on recent server flush is disabled
57
57
  end
58
- end
58
+ end if ENV['COUCHBASE_FLUSH_BUCKETS']
59
59
  end
60
60
  def stop; end
61
61
  end
@@ -166,6 +166,13 @@ class MiniTest::Unit::TestCase
166
166
  end
167
167
 
168
168
  def uniq_id(*suffixes)
169
- [caller.first[/.*[` ](.*)'/, 1], suffixes].join("_")
169
+ test_id = [caller.first[/.*[` ](.*)'/, 1], suffixes].compact.join("_")
170
+ @ids ||= {}
171
+ @ids[test_id] ||= Time.now.to_f
172
+ [test_id, @ids[test_id]].join("_")
173
+ end
174
+
175
+ def after_teardown
176
+ GC.start
170
177
  end
171
178
  end
@@ -54,6 +54,43 @@ class TestArithmetic < MiniTest::Unit::TestCase
54
54
  end
55
55
  end
56
56
 
57
+ def test_it_allows_to_make_increments_less_verbose_by_forcing_create_by_default
58
+ connection = Couchbase.connect(:hostname => @mock.host, :port => @mock.port,
59
+ :default_arithmetic_init => true)
60
+ assert_raises(Couchbase::Error::NotFound) do
61
+ connection.get(uniq_id)
62
+ end
63
+ assert_equal 0, connection.incr(uniq_id), "return value"
64
+ assert_equal 0, connection.get(uniq_id), "via get command"
65
+ end
66
+
67
+ def test_it_allows_to_setup_initial_value_during_connection
68
+ connection = Couchbase.connect(:hostname => @mock.host, :port => @mock.port,
69
+ :default_arithmetic_init => 10)
70
+ assert_raises(Couchbase::Error::NotFound) do
71
+ connection.get(uniq_id)
72
+ end
73
+ assert_equal 10, connection.incr(uniq_id), "return value"
74
+ assert_equal 10, connection.get(uniq_id), "via get command"
75
+ end
76
+
77
+ def test_it_allows_to_change_default_initial_value_after_connection
78
+ connection = Couchbase.connect(:hostname => @mock.host, :port => @mock.port)
79
+
80
+ assert_equal 0, connection.default_arithmetic_init
81
+ assert_raises(Couchbase::Error::NotFound) do
82
+ connection.incr(uniq_id)
83
+ end
84
+
85
+ connection.default_arithmetic_init = 10
86
+ assert_equal 10, connection.default_arithmetic_init
87
+ assert_raises(Couchbase::Error::NotFound) do
88
+ connection.get(uniq_id)
89
+ end
90
+ assert_equal 10, connection.incr(uniq_id), "return value"
91
+ assert_equal 10, connection.get(uniq_id), "via get command"
92
+ end
93
+
57
94
  def test_it_creates_missing_key_when_initial_value_specified
58
95
  connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
59
96
 
data/test/test_async.rb CHANGED
@@ -124,7 +124,7 @@ class TestAsync < MiniTest::Unit::TestCase
124
124
  connection.run do |conn|
125
125
  conn.delete(uniq_id, :cas => cas) do |res1|
126
126
  success = res1.success?
127
- conn.get(uniq_id) do |res2|
127
+ conn.get(uniq_id, :quiet => true) do |res2|
128
128
  val = res2.value
129
129
  end
130
130
  end
@@ -154,27 +154,31 @@ class TestAsync < MiniTest::Unit::TestCase
154
154
  end
155
155
 
156
156
  def test_nested_async_flush_set
157
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
158
- cas = connection.set(uniq_id, "foo")
159
- res = {}
157
+ if @mock.real?
158
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
159
+ cas = connection.set(uniq_id, "foo")
160
+ res = {}
160
161
 
161
- connection.run do |conn|
162
- conn.flush do |res1|
163
- assert res1.success?
164
- id = uniq_id(res1.node)
165
- res[id] = false
166
- conn.set(id, true) do |res2|
167
- res[id] = res2.cas
162
+ connection.run do |conn|
163
+ conn.flush do |res1|
164
+ assert res1.success?, "Expected: successful status code.\nActual: #{res1.error.inspect}"
165
+ id = uniq_id(res1.node)
166
+ res[id] = false
167
+ conn.set(id, true) do |res2|
168
+ res[id] = res2.cas
169
+ end
168
170
  end
169
171
  end
170
- end
171
172
 
172
- assert_raises(Couchbase::Error::NotFound) do
173
- connection.get(uniq_id)
174
- end
175
- res.keys.each do |key|
176
- assert res[key].is_a?(Numeric)
177
- assert connection.get(key)
173
+ assert_raises(Couchbase::Error::NotFound) do
174
+ connection.get(uniq_id)
175
+ end
176
+ res.keys.each do |key|
177
+ assert res[key].is_a?(Numeric)
178
+ assert connection.get(key)
179
+ end
180
+ else
181
+ skip("REST FLUSH isn't implemented in CouchbaseMock.jar yet")
178
182
  end
179
183
  end
180
184
 
data/test/test_unlock.rb CHANGED
@@ -71,7 +71,6 @@ class TestTouch < MiniTest::Unit::TestCase
71
71
  end
72
72
  ret = connection.unlock(uniq_id(1) => info[uniq_id(1)][2],
73
73
  uniq_id(2) => info[uniq_id(2)][2])
74
- puts ret.inspect
75
74
  assert ret[uniq_id(1)]
76
75
  assert ret[uniq_id(2)]
77
76
  connection.set(uniq_id(1), "bar")
data/test/test_utils.rb CHANGED
@@ -19,8 +19,40 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestUtils < MiniTest::Unit::TestCase
21
21
 
22
+ def setup
23
+ @mock = start_mock
24
+ end
25
+
26
+ def teardown
27
+ stop_mock(@mock)
28
+ end
29
+
22
30
  def test_complex_startkey
23
31
  assert_equal "all_docs?startkey=%5B%22Deadmau5%22%2C%22%22%5D", Couchbase::Utils.build_query("all_docs", :startkey => ["Deadmau5", ""])
24
32
  end
25
33
 
34
+ def test_it_provides_enough_info_with_value_error
35
+ class << MultiJson
36
+ alias dump_good dump
37
+ def dump(obj)
38
+ raise ArgumentError, "cannot accept your object"
39
+ end
40
+ end
41
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
42
+ assert_raises(Couchbase::Error::ValueFormat) do
43
+ connection.set(uniq_id, "foo")
44
+ end
45
+ begin
46
+ connection.set(uniq_id, "foo")
47
+ rescue Couchbase::Error::ValueFormat => ex
48
+ assert_match /cannot accept your object/, ex.to_s
49
+ assert_instance_of ArgumentError, ex.inner_exception
50
+ end
51
+ ensure
52
+ class << MultiJson
53
+ undef dump
54
+ alias dump dump_good
55
+ end
56
+ end
57
+
26
58
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.z.beta
5
- prerelease: 6
4
+ version: 1.2.1
5
+ prerelease:
6
6
  platform: x86-mingw32
7
7
  authors:
8
8
  - Couchbase
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-18 00:00:00.000000000 Z
12
+ date: 2012-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yaji
@@ -171,22 +171,6 @@ dependencies:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
173
  version: 1.1.0
174
- - !ruby/object:Gem::Dependency
175
- name: debugger
176
- requirement: !ruby/object:Gem::Requirement
177
- none: false
178
- requirements:
179
- - - ! '>='
180
- - !ruby/object:Gem::Version
181
- version: '0'
182
- type: :development
183
- prerelease: false
184
- version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
- requirements:
187
- - - ! '>='
188
- - !ruby/object:Gem::Version
189
- version: '0'
190
174
  - !ruby/object:Gem::Dependency
191
175
  name: active_support
192
176
  requirement: !ruby/object:Gem::Requirement
@@ -213,9 +197,10 @@ files:
213
197
  - .travis.yml
214
198
  - .yardopts
215
199
  - Gemfile
216
- - HISTORY.markdown
217
200
  - LICENSE
201
+ - Makefile
218
202
  - README.markdown
203
+ - RELEASE_NOTES.markdown
219
204
  - Rakefile
220
205
  - couchbase.gemspec
221
206
  - ext/couchbase_ext/.gitignore
@@ -229,6 +214,7 @@ files:
229
214
  - ext/couchbase_ext/get.c
230
215
  - ext/couchbase_ext/gethrtime.c
231
216
  - ext/couchbase_ext/http.c
217
+ - ext/couchbase_ext/multithread_plugin.c
232
218
  - ext/couchbase_ext/observe.c
233
219
  - ext/couchbase_ext/result.c
234
220
  - ext/couchbase_ext/stats.c
@@ -242,6 +228,7 @@ files:
242
228
  - lib/active_support/cache/couchbase_store.rb
243
229
  - lib/couchbase.rb
244
230
  - lib/couchbase/bucket.rb
231
+ - lib/couchbase/cluster.rb
245
232
  - lib/couchbase/result.rb
246
233
  - lib/couchbase/utils.rb
247
234
  - lib/couchbase/version.rb
@@ -293,13 +280,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
280
  version: '0'
294
281
  segments:
295
282
  - 0
296
- hash: 2121319828183338938
283
+ hash: 1784186520908276694
297
284
  required_rubygems_version: !ruby/object:Gem::Requirement
298
285
  none: false
299
286
  requirements:
300
- - - ! '>'
287
+ - - ! '>='
301
288
  - !ruby/object:Gem::Version
302
- version: 1.3.1
289
+ version: '0'
290
+ segments:
291
+ - 0
292
+ hash: 1784186520908276694
303
293
  requirements: []
304
294
  rubyforge_project:
305
295
  rubygems_version: 1.8.23