rethinkdb 1.10.0.1 → 1.11.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/net.rb +54 -16
  3. data/lib/ql2.pb.rb +8 -0
  4. data/lib/shim.rb +3 -1
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59e79e6d9c3439b65c7eb4d100996304062ea23a
4
- data.tar.gz: f56d759a19a9db15fe6affbd712c54a5cdee2e5a
3
+ metadata.gz: 003e171146b67e41c8f89bf9c85f21f6860dace3
4
+ data.tar.gz: 34fc0e2e3df5e8655d12e6b6d402784e7a390a49
5
5
  SHA512:
6
- metadata.gz: 79020581d60bd00e3fe43f49e14ac3c4d6282ace1655ce019aa6bd1f8502289668cc287d178a9b2f852b5579917a759a7e583ffac3b3ecb99d08f061604c5054
7
- data.tar.gz: e17aa512ff7ef6710b17dae2386ae650e1956d5fba4e27b7780a133e133362fa6e1dd0d60720871a4535f5838077ff2ffca6014b1bd8efbd9e07f225f365d84d
6
+ metadata.gz: 6ae00357bc05acf7cb924aa63c919d3f40da606e0141be9c073548e669bc2c738a94c38400aac13ffb536fe6a45252c691ae7dfd77d3fe04aa8856e4b289b8f1
7
+ data.tar.gz: d80dfbcb3236697469b8555aa734840cac09cda41e60d6daa1e637780069b99ff08b9dfc81f218eef10b01c1b0a9bb8d46ff08ed40d894f4b963bf043b641c24
data/lib/net.rb CHANGED
@@ -6,6 +6,14 @@ require 'timeout'
6
6
  # $f = File.open("fuzz_seed.rb", "w")
7
7
 
8
8
  module RethinkDB
9
+ def self.new_query(type, token)
10
+ q = Query.new
11
+ q.type = type
12
+ q.accepts_r_json = true
13
+ q.token = token
14
+ return q
15
+ end
16
+
9
17
  module Faux_Abort
10
18
  class Abort
11
19
  end
@@ -70,9 +78,7 @@ module RethinkDB
70
78
  while true
71
79
  @results.each(&block)
72
80
  return self if !@more
73
- q = Query.new
74
- q.type = Query::QueryType::CONTINUE
75
- q.token = @token
81
+ q = RethinkDB::new_query(Query::QueryType::CONTINUE, @token)
76
82
  res = @conn.run_internal q
77
83
  @results = Shim.response_to_native(res, @msg, @opts)
78
84
  if res.type == Response::ResponseType::SUCCESS_SEQUENCE
@@ -105,7 +111,7 @@ module RethinkDB
105
111
  @@last = self
106
112
  @default_opts = default_db ? {:db => RQL.new.db(default_db)} : {}
107
113
  @conn_id = 0
108
- reconnect
114
+ reconnect(:noreply_wait => false)
109
115
  end
110
116
  attr_reader :default_db, :conn_id
111
117
 
@@ -115,12 +121,10 @@ module RethinkDB
115
121
  noreply ? nil : wait(q.token)
116
122
  end
117
123
  def run(msg, opts)
118
- reconnect if @auto_reconnect && (!@socket || !@listener)
119
- raise RuntimeError, "Error: Connection Closed." if !@socket || !@listener
120
- q = Query.new
121
- q.type = Query::QueryType::START
124
+ reconnect(:noreply_wait => false) if @auto_reconnect && (!@socket || !@listener)
125
+ raise RqlRuntimeError, "Error: Connection Closed." if !@socket || !@listener
126
+ q = RethinkDB::new_query(Query::QueryType::START, @@token_cnt += 1)
122
127
  q.query = msg
123
- q.token = @@token_cnt += 1
124
128
 
125
129
  all_opts = @default_opts.merge(opts)
126
130
  if all_opts.keys.include?(:noreply)
@@ -140,13 +144,20 @@ module RethinkDB
140
144
  res = run_internal(q, all_opts[:noreply])
141
145
  return res if !res
142
146
  if res.type == Response::ResponseType::SUCCESS_PARTIAL
143
- Cursor.new(Shim.response_to_native(res, msg, opts),
147
+ value = Cursor.new(Shim.response_to_native(res, msg, opts),
144
148
  msg, self, opts, q.token, true)
145
149
  elsif res.type == Response::ResponseType::SUCCESS_SEQUENCE
146
- Cursor.new(Shim.response_to_native(res, msg, opts),
150
+ value = Cursor.new(Shim.response_to_native(res, msg, opts),
147
151
  msg, self, opts, q.token, false)
148
152
  else
149
- Shim.response_to_native(res, msg, opts)
153
+ value = Shim.response_to_native(res, msg, opts)
154
+ end
155
+
156
+ if res.respond_to? :has_profile? and res.has_profile?
157
+ {"profile" => Shim.datum_to_native(res.profile(), opts),
158
+ "value" => value}
159
+ else
160
+ value
150
161
  end
151
162
  end
152
163
 
@@ -174,7 +185,7 @@ module RethinkDB
174
185
  return res
175
186
  rescue @abort_module::Abort => e
176
187
  print "\nAborting query and reconnecting...\n"
177
- reconnect
188
+ reconnect(:noreply_wait => false)
178
189
  raise e
179
190
  end
180
191
  end
@@ -197,8 +208,17 @@ module RethinkDB
197
208
  def debug_socket; @socket; end
198
209
 
199
210
  # Reconnect to the server. This will interrupt all queries on the
200
- # server and invalidate all outstanding enumerables on the client.
201
- def reconnect
211
+ # server (if :noreply_wait => false) and invalidate all outstanding
212
+ # enumerables on the client.
213
+ def reconnect(opts={})
214
+ raise ArgumentError, "Argument to reconnect must be a hash." if opts.class != Hash
215
+ if not (opts.keys - [:noreply_wait]).empty?
216
+ raise ArgumentError, "reconnect does not understand these options: " +
217
+ (opts.keys - [:noreply_wait]).to_s
218
+ end
219
+ opts[:noreply_wait] = true if not opts.keys.include?(:noreply_wait)
220
+
221
+ self.noreply_wait() if opts[:noreply_wait]
202
222
  @socket.close if @socket
203
223
  @socket = TCPSocket.open(@host, @port)
204
224
  @waiters = {}
@@ -209,13 +229,31 @@ module RethinkDB
209
229
  self
210
230
  end
211
231
 
212
- def close
232
+ def close(opts={})
233
+ raise ArgumentError, "Argument to close must be a hash." if opts.class != Hash
234
+ if not (opts.keys - [:noreply_wait]).empty?
235
+ raise ArgumentError, "close does not understand these options: " +
236
+ (opts.keys - [:noreply_wait]).to_s
237
+ end
238
+ opts[:noreply_wait] = true if not opts.keys.include?(:noreply_wait)
239
+
240
+ self.noreply_wait() if opts[:noreply_wait]
213
241
  @listener.terminate if @listener
214
242
  @listener = nil
215
243
  @socket.close
216
244
  @socket = nil
217
245
  end
218
246
 
247
+ def noreply_wait
248
+ raise RqlRuntimeError, "Error: Connection Closed." if !@socket || !@listener
249
+ q = RethinkDB::new_query(Query::QueryType::NOREPLY_WAIT, @@token_cnt += 1)
250
+ res = run_internal(q)
251
+ if res.type != Response::ResponseType::WAIT_COMPLETE
252
+ raise RqlRuntimeError, "Unexpected response to noreply_wait: " + PP.pp(res, "")
253
+ end
254
+ nil
255
+ end
256
+
219
257
  def self.last
220
258
  return @@last if @@last
221
259
  raise RqlRuntimeError, "No last connection. Use RethinkDB::Connection.new."
data/lib/ql2.pb.rb CHANGED
@@ -42,6 +42,7 @@ class Query < ::ProtocolBuffers::Message
42
42
  START = 1
43
43
  CONTINUE = 2
44
44
  STOP = 3
45
+ NOREPLY_WAIT = 4
45
46
  end
46
47
 
47
48
  set_fully_qualified_name "Query"
@@ -58,6 +59,7 @@ class Query < ::ProtocolBuffers::Message
58
59
  optional ::Term, :query, 2
59
60
  optional :int64, :token, 3
60
61
  optional :bool, :OBSOLETE_noreply, 4, :default => false
62
+ optional :bool, :accepts_r_json, 5, :default => false
61
63
  repeated ::Query::AssocPair, :global_optargs, 6
62
64
  end
63
65
 
@@ -99,6 +101,7 @@ class Response < ::ProtocolBuffers::Message
99
101
  SUCCESS_ATOM = 1
100
102
  SUCCESS_SEQUENCE = 2
101
103
  SUCCESS_PARTIAL = 3
104
+ WAIT_COMPLETE = 4
102
105
  CLIENT_ERROR = 16
103
106
  COMPILE_ERROR = 17
104
107
  RUNTIME_ERROR = 18
@@ -110,6 +113,7 @@ class Response < ::ProtocolBuffers::Message
110
113
  optional :int64, :token, 2
111
114
  repeated ::Datum, :response, 3
112
115
  optional ::Backtrace, :backtrace, 4
116
+ optional ::Datum, :profile, 5
113
117
  end
114
118
 
115
119
  class Datum < ::ProtocolBuffers::Message
@@ -128,6 +132,7 @@ class Datum < ::ProtocolBuffers::Message
128
132
  R_STR = 4
129
133
  R_ARRAY = 5
130
134
  R_OBJECT = 6
135
+ R_JSON = 7
131
136
  end
132
137
 
133
138
  set_fully_qualified_name "Datum"
@@ -233,9 +238,12 @@ class Term < ::ProtocolBuffers::Message
233
238
  TABLE_CREATE = 60
234
239
  TABLE_DROP = 61
235
240
  TABLE_LIST = 62
241
+ SYNC = 138
236
242
  INDEX_CREATE = 75
237
243
  INDEX_DROP = 76
238
244
  INDEX_LIST = 77
245
+ INDEX_STATUS = 139
246
+ INDEX_WAIT = 140
239
247
  FUNCALL = 64
240
248
  BRANCH = 65
241
249
  ANY = 66
data/lib/shim.rb CHANGED
@@ -21,7 +21,9 @@ module RethinkDB
21
21
  else
22
22
  obj
23
23
  end
24
- else raise RqlRuntimeError, "Unimplemented."
24
+ when dt::R_JSON then
25
+ JSON.parse("[" + d.r_str + "]")[0]
26
+ else raise RqlRuntimeError, "#{dt} Unimplemented."
25
27
  end
26
28
  end
27
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rethinkdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0.1
4
+ version: 1.11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RethinkDB Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-30 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -46,11 +46,11 @@ extra_rdoc_files: []
46
46
  files:
47
47
  - lib/exc.rb
48
48
  - lib/ql2.pb.rb
49
- - lib/net.rb
50
49
  - lib/rethinkdb.rb
51
50
  - lib/rpp.rb
52
- - lib/shim.rb
53
51
  - lib/func.rb
52
+ - lib/net.rb
53
+ - lib/shim.rb
54
54
  homepage: http://rethinkdb.com
55
55
  licenses:
56
56
  - Apache-2