libcouchbase 0.3.1 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5997fa863626ca0ef4723becd7d60ddbbcb3425f
4
- data.tar.gz: 43edae591acdd1a6146db06da0c97c4267e6c1ef
3
+ metadata.gz: 5e109b474ba52c5f517c1d56bb11decfcce96079
4
+ data.tar.gz: 0bf3dcda70e298bdd5121199875a0a05552b304d
5
5
  SHA512:
6
- metadata.gz: 5357cad71cf73c2e3c649a74692c613cd386cd07bb3d0c2f97117f3ca75f3d912230bf6d122e5fb59d0634acaec279caddbab2fe1b26f5bd64e13c3a5afe40a2
7
- data.tar.gz: be6d945d52b776287dd469a61781a2c5099f7eabf905be786fd946bfcb21c16ae387a97478f59fe5e0e58db006588d45f63bea79ef1270392880d1baa540cffa
6
+ metadata.gz: 5e46bd8fe2c97bc6ed242cbe49b16d670407839a5a39bea4ba872b68a2065d2bf0e41e52bb4116f919d1cd95b3c46a6e7937d70ab3550e2c877dae04b0410700
7
+ data.tar.gz: 641f6bb07307a0e4c95937c11c9278100dc486d165de84e4ecc677d20534555b0157e52aa8913278f11cb719cb1b19d1af443012182bde6f53e1bdc2ab0163d4
data/.travis.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ruby-2.3.1
4
- - ruby-2.2.5
3
+ - ruby-2.4.1
4
+ - ruby-2.3.4
5
5
  - ruby-head
6
- - jruby-9.1.5.0
6
+ - jruby-9.1.10.0
7
7
  - jruby-head
8
8
  - rubinius
9
- - rubinius-3.76
9
+ - rubinius-3.78
10
10
  branches:
11
11
  only:
12
12
  - master
@@ -14,8 +14,8 @@ before_install:
14
14
  - git submodule update --init --recursive
15
15
  - gem install ffi
16
16
  - sudo apt-get install libev-dev
17
- - sudo wget https://packages.couchbase.com/releases/4.6.1/couchbase-server-enterprise_4.6.1-ubuntu14.04_amd64.deb
18
- - sudo dpkg -i couchbase-server-enterprise_4.6.1-ubuntu14.04_amd64.deb
17
+ - sudo wget https://packages.couchbase.com/releases/4.6.2/couchbase-server-enterprise_4.6.2-ubuntu14.04_amd64.deb
18
+ - sudo dpkg -i couchbase-server-enterprise_4.6.2-ubuntu14.04_amd64.deb
19
19
  - sleep 4
20
20
  - sudo service couchbase-server status
21
21
  - /opt/couchbase/bin/couchbase-cli cluster-init -c 127.0.0.1:8091 --cluster-username=admin --cluster-password=password --cluster-ramsize=320 --cluster-index-ramsize=256 --cluster-fts-ramsize=256 --services=data,index,query,fts
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ require File.expand_path('../lib/libcouchbase/ext/tasks', __FILE__) # platfor
11
11
  task :default => :limited_spec
12
12
  RSpec::Core::RakeTask.new(:limited_spec) do |t|
13
13
  # Exclude full text search tests until we can automate index creation
14
- t.rspec_opts = "--tag ~full_text_search --tag ~n1ql_query"
14
+ t.rspec_opts = "--tag ~full_text_search --tag ~n1ql_query --fail-fast"
15
15
  end
16
16
  RSpec::Core::RakeTask.new(:spec)
17
17
 
@@ -3,11 +3,21 @@
3
3
  require 'json'
4
4
 
5
5
 
6
- at_exit do
7
- ObjectSpace.each_object(::Libcouchbase::Connection).each do |connection|
8
- connection.destroy.finally do
9
- connection.reactor.stop
6
+ # Not required on jruby - buckets are cleaned up by GC
7
+ unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
8
+ at_exit do
9
+ GC.start
10
+ connections = []
11
+ ObjectSpace.each_object(::Libcouchbase::Connection).each do |connection|
12
+ next unless connection.reactor.running?
13
+ connections << connection
14
+ begin
15
+ connection.destroy
16
+ rescue => e
17
+ end
10
18
  end
19
+ sleep 2 if connections.length > 0
20
+ connections.each { |c| c.reactor.stop }
11
21
  end
12
22
  end
13
23
 
@@ -136,7 +146,8 @@ module Libcouchbase
136
146
  err = Ext.connect(@handle)
137
147
  if err != :success
138
148
  @bootstrap_defer.reject(Error.lookup(err).new('failed to schedule connect'))
139
- destroy
149
+ Ext.destroy(@handle)
150
+ handle_destroyed
140
151
  end
141
152
  end
142
153
  }
@@ -165,17 +176,21 @@ module Libcouchbase
165
176
  end
166
177
 
167
178
  def destroy
168
- defer = @reactor.defer
179
+ raise 'not connected' unless @handle
180
+ return @destroy_defer.promise if @destroy_defer
169
181
 
170
182
  # Ensure it is thread safe
183
+ defer = @reactor.defer
171
184
  @reactor.schedule {
172
- if @handle
185
+ if @destroy_defer.nil?
186
+ @destroy_defer = defer
173
187
  Ext.destroy(@handle)
174
188
  handle_destroyed
189
+ defer.resolve(nil)
190
+ else
191
+ defer.resolve(@destroy_defer.promise)
175
192
  end
176
- defer.resolve(self)
177
193
  }
178
-
179
194
  defer.promise
180
195
  end
181
196
 
@@ -830,6 +830,11 @@ module Libcouchbase::Ext
830
830
  :unknown_sdcmd, 77,
831
831
  :eno_commands, 78,
832
832
  :query_error, 79,
833
+ :generic_tmperr, 80,
834
+ :generic_subdocerr, 81,
835
+ :generic_constraint_err, 82,
836
+ :nameserver_error, 83,
837
+ :not_authorized, 84,
833
838
  :max_error, 4096
834
839
  ]
835
840
 
@@ -37,14 +37,17 @@ module Libcouchbase
37
37
  @fiber = Fiber.current
38
38
 
39
39
  begin
40
- while !@query_completed || (cont = @results.length > 0) do
41
- if cont
40
+ remaining = @results.length > 0
41
+ while !@query_completed || remaining do
42
+ if remaining
42
43
  @resume_results = false
43
44
  yield @results.shift
44
45
  else
45
46
  @resume_results = true
46
47
  resume
47
48
  end
49
+
50
+ remaining = @results.length > 0
48
51
  end
49
52
  ensure
50
53
  # cancel is executed on break or error
@@ -71,13 +74,13 @@ module Libcouchbase
71
74
  @results.each &blk
72
75
  else
73
76
  perform
74
-
75
- index = 0
76
77
  @fiber = Fiber.current
77
78
 
78
79
  begin
79
- while !@query_completed || (cont = index < @results.length) do
80
- if cont
80
+ index = 0
81
+ remaining = index < @results.length
82
+ while !@query_completed || remaining do
83
+ if remaining
81
84
  @resume_results = false
82
85
  yield @results[index]
83
86
  index += 1
@@ -85,6 +88,8 @@ module Libcouchbase
85
88
  @resume_results = true
86
89
  resume
87
90
  end
91
+
92
+ remaining = index < @results.length
88
93
  end
89
94
  ensure
90
95
  # cancel is executed on break or error
@@ -126,19 +131,21 @@ module Libcouchbase
126
131
  @results[0...num]
127
132
  else
128
133
  perform is_complete: false, limit: num
129
-
130
- index = 0
131
134
  @fiber = Fiber.current
132
-
133
135
  result = []
136
+
134
137
  begin
135
- while !@query_completed || (cont = index < @results.length && index < num) do
136
- if cont
138
+ index = 0
139
+ remaining = index < @results.length && index < num
140
+ while !@query_completed || remaining do
141
+ if remaining
137
142
  result << @results[index]
138
143
  index += 1
139
144
  else
140
145
  resume
141
146
  end
147
+
148
+ remaining = index < @results.length && index < num
142
149
  end
143
150
  ensure
144
151
  @fiber = nil
@@ -27,12 +27,15 @@ module Libcouchbase
27
27
  else
28
28
  perform is_complete: false
29
29
  begin
30
- while !@query_completed || (cont = @results.length > 0) do
31
- if cont
30
+ remaining = @results.length > 0
31
+ while !@query_completed || remaining do
32
+ if remaining
32
33
  yield @results.shift
33
34
  else
34
35
  process_next_item
35
36
  end
37
+
38
+ remaining = @results.length > 0
36
39
  end
37
40
  ensure
38
41
  # cancel is executed on break or error
@@ -62,13 +65,16 @@ module Libcouchbase
62
65
 
63
66
  begin
64
67
  index = 0
65
- while !@query_completed || (cont = index < @results.length) do
66
- if cont
68
+ remaining = index < @results.length
69
+ while !@query_completed || remaining do
70
+ if remaining
67
71
  yield @results[index]
68
72
  index += 1
69
73
  else
70
74
  process_next_item
71
75
  end
76
+
77
+ remaining = index < @results.length
72
78
  end
73
79
  ensure
74
80
  # cancel is executed on break or error
@@ -109,13 +115,16 @@ module Libcouchbase
109
115
 
110
116
  index = 0
111
117
  result = []
112
- while !@query_completed || (cont = index < @results.length && index < num) do
113
- if cont
118
+ remaining = index < @results.length && index < num
119
+ while !@query_completed || remaining do
120
+ if remaining
114
121
  result << @results[index]
115
122
  index += 1
116
123
  else
117
124
  process_next_item
118
125
  end
126
+
127
+ remaining = index < @results.length && index < num
119
128
  end
120
129
 
121
130
  raise @error if @error
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true, encoding: ASCII-8BIT
2
2
 
3
3
  module Libcouchbase
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.3'
5
5
  end
@@ -221,7 +221,7 @@ describe Libcouchbase::Connection do
221
221
  expect(@log).to eq([:success])
222
222
  end
223
223
 
224
- it "should flush when enabled explicitly" do
224
+ it "should flush when enabled explicitly", flush: true do
225
225
  @reactor.run { |reactor|
226
226
  connection = Libcouchbase::Connection.new(bucket: :test, password: 'password123')
227
227
  connection.connect(flush_enabled: true).then do
@@ -3,7 +3,7 @@
3
3
  require 'libcouchbase'
4
4
 
5
5
 
6
- describe Libcouchbase::DesignDocs do
6
+ describe Libcouchbase::DesignDocs, design_docs: true do
7
7
  before :each do
8
8
  @ddoc = Libcouchbase::Bucket.new.design_docs
9
9
  end
@@ -64,20 +64,35 @@ describe Libcouchbase::ResultsLibuv do
64
64
  before :each do
65
65
  @log = []
66
66
  @reactor = ::Libuv::Reactor.default
67
+ @reactor.notifier do |err|
68
+ @reactor.stop
69
+ @log << err
70
+ end
71
+ @timeout = @reactor.timer do
72
+ @timeout.close
73
+ @reactor.stop
74
+ @log << "test timed out"
75
+ end
76
+ @timeout.start(5000)
77
+ @timeout.unref
67
78
  @query = MockQuery.new(@log)
68
79
  @view = Libcouchbase::ResultsLibuv.new(@query)
69
80
  expect(@log).to eq([])
70
81
  end
71
82
 
83
+ after :each do
84
+ @timeout.close
85
+ end
86
+
72
87
  it "should stream the response" do
73
88
  @reactor.run { |reactor|
74
89
  @view.each {|i| @log << i }
75
90
  }
76
91
 
92
+ expect(@log).to eq([:new_row, 0, :new_row, 1, :new_row, 2, :new_row, 3])
77
93
  expect(@view.complete_result_set).to be(true)
78
94
  expect(@view.query_in_progress).to be(false)
79
95
  expect(@view.query_completed).to be(true)
80
- expect(@log).to eq([:new_row, 0, :new_row, 1, :new_row, 2, :new_row, 3])
81
96
  end
82
97
 
83
98
  it "should continue to stream the response even if some has already been loaded" do
@@ -173,7 +173,7 @@ describe Libcouchbase::ResultsNative do
173
173
 
174
174
  @query.wait_join
175
175
 
176
- expect(@qlog).to eq([:new_row, :new_row, :new_row, :new_row])
176
+ expect(@qlog).to eq([:new_row])
177
177
  expect(@log).to eq([0, 'what what'])
178
178
  end
179
179
 
@@ -241,7 +241,7 @@ describe Libcouchbase::ResultsNative do
241
241
 
242
242
  @query.wait_join
243
243
 
244
- expect(@qlog).to eq([:new_row, :new_row])
244
+ expect(@qlog).to eq([:new_row])
245
245
  expect(@log).to eq([0, 'first'])
246
246
  end
247
247
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libcouchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -751,7 +751,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
751
751
  version: '0'
752
752
  requirements: []
753
753
  rubyforge_project:
754
- rubygems_version: 2.6.10
754
+ rubygems_version: 2.6.12
755
755
  signing_key:
756
756
  specification_version: 4
757
757
  summary: libcouchbase bindings for Ruby