tarantool 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -3
- data/README.md +7 -8
- data/examples/em_simple.rb +7 -9
- data/lib/tarantool.rb +1 -1
- data/lib/tarantool/request.rb +2 -11
- data/spec/tarantool/em_spec.rb +7 -9
- data/spec/tarantool/request_spec.rb +0 -11
- data/tarantool.gemspec +3 -3
- metadata +7 -7
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tarantool (0.
|
4
|
+
tarantool (0.2)
|
5
5
|
activemodel (>= 3.1, < 4.0)
|
6
|
-
iproto (>= 0.
|
6
|
+
iproto (>= 0.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
eventmachine (>= 1.0.0.beta.1)
|
24
24
|
eventmachine (1.0.0.beta.4)
|
25
25
|
i18n (0.6.0)
|
26
|
-
iproto (0.
|
26
|
+
iproto (0.2)
|
27
27
|
linecache19 (0.5.12)
|
28
28
|
ruby_core_source (>= 0.1.4)
|
29
29
|
multi_json (1.0.3)
|
data/README.md
CHANGED
@@ -38,15 +38,14 @@ To use EventMachine pass type: em in options:
|
|
38
38
|
|
39
39
|
```ruby
|
40
40
|
require 'em-synchrony'
|
41
|
-
DB = Tarantool.new host: 'locahost', port: 33013
|
42
|
-
space = DB.space 0
|
41
|
+
DB = Tarantool.new host: 'locahost', port: 33013, type: :em
|
43
42
|
EM.synchrony do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
space = DB.space 0
|
44
|
+
space.insert 'prepor', 'Andrew', 'ceo@prepor.ru'
|
45
|
+
res = space.select 'prepor'
|
46
|
+
puts "Name: #{res.tuple[1].to_s}; Email: #{res.tuple[2].to_s}"
|
47
|
+
space.delete 'prepor'
|
48
|
+
EM.stop
|
50
49
|
end
|
51
50
|
```
|
52
51
|
|
data/examples/em_simple.rb
CHANGED
@@ -5,14 +5,12 @@ Bundler.setup
|
|
5
5
|
require 'tarantool'
|
6
6
|
|
7
7
|
require 'em-synchrony'
|
8
|
-
DB = Tarantool.new host: 'localhost', port: 33013
|
9
|
-
space = DB.space 0
|
8
|
+
DB = Tarantool.new host: 'localhost', port: 33013, type: :em
|
10
9
|
EM.synchrony do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end.resume
|
10
|
+
space = DB.space 0
|
11
|
+
space.insert 'prepor', 'Andrew', 'ceo@prepor.ru'
|
12
|
+
res = space.select 'prepor'
|
13
|
+
puts "Name: #{res.tuple[1].to_s}; Email: #{res.tuple[2].to_s}"
|
14
|
+
space.delete 'prepor'
|
15
|
+
EM.stop
|
18
16
|
end
|
data/lib/tarantool.rb
CHANGED
data/lib/tarantool/request.rb
CHANGED
@@ -47,7 +47,7 @@ class Tarantool
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def perform
|
50
|
-
data = connection.
|
50
|
+
data = connection.send_request self.class.request_type, make_body
|
51
51
|
make_response data
|
52
52
|
end
|
53
53
|
|
@@ -55,17 +55,8 @@ class Tarantool
|
|
55
55
|
|
56
56
|
end
|
57
57
|
|
58
|
-
def request_id
|
59
|
-
@request_id ||= connection.next_request_id
|
60
|
-
end
|
61
|
-
|
62
|
-
def make_packet(body)
|
63
|
-
[self.class.request_type, body.size, request_id].pack('LLL') +
|
64
|
-
body
|
65
|
-
end
|
66
|
-
|
67
58
|
def make_response(data)
|
68
|
-
return_code,
|
59
|
+
return_code, = data[0,4].unpack('L')
|
69
60
|
if return_code == 0
|
70
61
|
Response.new(data[4, data.size], response_params)
|
71
62
|
else
|
data/spec/tarantool/em_spec.rb
CHANGED
@@ -9,15 +9,13 @@ describe "Tarantool with EM" do
|
|
9
9
|
describe "insert, select and delete" do
|
10
10
|
it "should insert tuple and return it" do
|
11
11
|
EM.synchrony do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
EM.stop
|
20
|
-
end.resume
|
12
|
+
space.insert 100, 'привет', return_tuple: true
|
13
|
+
res = space.select 100
|
14
|
+
int, string = res.tuple
|
15
|
+
int.to_i.must_equal 100
|
16
|
+
string.to_s.must_equal 'привет'
|
17
|
+
space.delete 100
|
18
|
+
EM.stop
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -31,17 +31,6 @@ describe Tarantool::Request do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe "instance" do
|
35
|
-
let(:request) { Tarantool::Requests::Insert.new space }
|
36
|
-
|
37
|
-
it "should make packet with right request type, body size and next request id + body" do
|
38
|
-
body = 'hi'
|
39
|
-
expect = [Tarantool::Requests::REQUEST_TYPES[:insert], body.bytesize, request.request_id].pack('LLL') + body
|
40
|
-
request.make_packet(body).must_equal expect
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
34
|
describe "requests" do
|
46
35
|
include Helpers::Truncate
|
47
36
|
describe "insert and select" do
|
data/tarantool.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'tarantool'
|
7
|
-
s.version = '0.2'
|
8
|
-
s.date = '2012-01-
|
7
|
+
s.version = '0.2.1'
|
8
|
+
s.date = '2012-01-27'
|
9
9
|
s.rubyforge_project = 'tarantool'
|
10
10
|
|
11
11
|
s.summary = "Tarantool KV-storage client."
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.rdoc_options = ["--charset=UTF-8"]
|
21
21
|
s.extra_rdoc_files = %w[README.md LICENSE]
|
22
22
|
|
23
|
-
s.add_dependency('iproto', [">= 0.
|
23
|
+
s.add_dependency('iproto', [">= 0.2"])
|
24
24
|
s.add_dependency('activemodel', [">= 3.1", "< 4.0"])
|
25
25
|
|
26
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tarantool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: iproto
|
16
|
-
requirement: &
|
16
|
+
requirement: &70184618798480 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0.
|
21
|
+
version: '0.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70184618798480
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|
27
|
-
requirement: &
|
27
|
+
requirement: &70184618796360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
version: '4.0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70184618796360
|
39
39
|
description: Tarantool KV-storage client.
|
40
40
|
email: ceo@prepor.ru
|
41
41
|
executables: []
|