rexpro 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/rexpro/client.rb +30 -13
- data/lib/rexpro/version.rb +1 -1
- data/rexpro.gemspec +4 -3
- data/spec/integration/integration_helper.rb +6 -3
- metadata +24 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 437d2e1d9f2ce37b553dac26e0b2af775d8b7c6f
|
4
|
+
data.tar.gz: 81593681ee7a9115fcc574829138665a7a4c0ab7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 87e774e300890256b7cbe674c588808a69f12bb685f485bdc6e7a0d8554061ce33ebc32a025802808d65dd7abc568de959a34eb1fb967fc46717cb25c99e7d3f
|
7
|
+
data.tar.gz: ad898a7b0f7c5fb8d6798c17f720e05b505bc636545469e93024c128ea9f00d9ddd8082dc6889494c66a68ebb47941c2a0394f56f039119dcf2a2b2fc067bc3a
|
data/lib/rexpro/client.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'tcp_timeout'
|
2
2
|
|
3
3
|
require_relative './session'
|
4
4
|
|
@@ -10,20 +10,27 @@ module Rexpro
|
|
10
10
|
attr_reader :host, :port, :socket
|
11
11
|
|
12
12
|
def initialize(opts = {})
|
13
|
-
|
14
|
-
@
|
13
|
+
opts = opts.dup
|
14
|
+
@host = opts.delete(:host) || DEFAULT_HOST
|
15
|
+
@port = opts.delete(:port) || DEFAULT_PORT
|
16
|
+
|
17
|
+
@request_opts = {}
|
18
|
+
[:channel, :graph_name, :graph_obj_name].each do |key|
|
19
|
+
value = opts.delete(key)
|
20
|
+
@request_opts[key] = value if value
|
21
|
+
end
|
22
|
+
|
23
|
+
@socket_opts = opts
|
15
24
|
reconnect
|
16
25
|
end
|
17
26
|
|
18
27
|
def reconnect
|
19
28
|
@socket.close if @socket && !@socket.closed?
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
resp = request(req)
|
26
|
-
Rexpro::Session.new(self, resp.session_uuid, req.channel, resp.languages)
|
29
|
+
begin
|
30
|
+
@socket = TCPTimeout::TCPSocket.new(@host, @port, @socket_opts)
|
31
|
+
rescue TCPTimeout::SocketTimeout => ex
|
32
|
+
raise Rexpro::RexproException.new(ex)
|
33
|
+
end
|
27
34
|
end
|
28
35
|
|
29
36
|
def request(req)
|
@@ -41,11 +48,21 @@ module Rexpro
|
|
41
48
|
raise Rexpro::RexproError.new(err_msg)
|
42
49
|
end
|
43
50
|
end
|
51
|
+
rescue TCPTimeout::SocketTimeout => ex
|
52
|
+
raise Rexpro::RexproException.new(ex)
|
53
|
+
end
|
54
|
+
|
55
|
+
def new_session(opts = {})
|
56
|
+
opts = @request_opts.merge(opts)
|
57
|
+
req = Rexpro::Message::SessionRequest.new(opts)
|
58
|
+
resp = request(req)
|
59
|
+
Rexpro::Session.new(self, resp.session_uuid, req.channel, resp.languages)
|
44
60
|
end
|
45
61
|
|
46
|
-
def execute(script,
|
47
|
-
|
48
|
-
|
62
|
+
def execute(script, opts = {})
|
63
|
+
opts = @request_opts.merge(opts)
|
64
|
+
opts[:script] = script
|
65
|
+
msg = Rexpro::Message::ScriptRequest.new(opts)
|
49
66
|
request(msg)
|
50
67
|
end
|
51
68
|
end
|
data/lib/rexpro/version.rb
CHANGED
data/rexpro.gemspec
CHANGED
@@ -13,15 +13,16 @@ Gem::Specification.new do |spec|
|
|
13
13
|
RexPro is a binary protocol for Rexster that can be used to send Gremlin
|
14
14
|
scripts to a remote Rexster instance.
|
15
15
|
DESC
|
16
|
-
spec.homepage = ""
|
16
|
+
spec.homepage = "https://github.com/lann/rexpro-ruby"
|
17
17
|
spec.license = "MIT"
|
18
18
|
|
19
19
|
spec.files = `git ls-files`.split($/)
|
20
20
|
spec.test_files = spec.files.grep(%r{^spec/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_dependency "msgpack",
|
24
|
-
spec.add_dependency "uuid",
|
23
|
+
spec.add_dependency "msgpack", "~> 0.5.4"
|
24
|
+
spec.add_dependency "uuid", "~> 2.3.7"
|
25
|
+
spec.add_dependency "tcp_timeout", "~> 0.1.1"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
28
|
spec.add_development_dependency "rake"
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module IntegrationHelper
|
2
2
|
def client_opts
|
3
|
-
%w[host port
|
4
|
-
|
5
|
-
|
3
|
+
%w[host port connect_timeout read_timeout write_timeout
|
4
|
+
].inject({}) do |memo, key|
|
5
|
+
if value = ENV["REXPRO_#{key.upcase}"]
|
6
|
+
value = value.to_i if value =~ /\A\d+$\z/
|
7
|
+
memo[key.to_sym] = value
|
8
|
+
end
|
6
9
|
memo
|
7
10
|
end
|
8
11
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexpro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Lann Martin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: msgpack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: uuid
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,15 +34,27 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 2.3.7
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tcp_timeout
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.1
|
46
55
|
- !ruby/object:Gem::Dependency
|
47
56
|
name: bundler
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
59
|
- - ~>
|
52
60
|
- !ruby/object:Gem::Version
|
@@ -54,7 +62,6 @@ dependencies:
|
|
54
62
|
type: :development
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
66
|
- - ~>
|
60
67
|
- !ruby/object:Gem::Version
|
@@ -62,17 +69,15 @@ dependencies:
|
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: rake
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - '>='
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
70
76
|
type: :development
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - '>='
|
76
81
|
- !ruby/object:Gem::Version
|
77
82
|
version: '0'
|
78
83
|
description: RexPro, a binary protocol for Rexster
|
@@ -98,30 +103,29 @@ files:
|
|
98
103
|
- spec/integration/integration_helper.rb
|
99
104
|
- spec/integration/session_spec.rb
|
100
105
|
- spec/message_spec.rb
|
101
|
-
homepage:
|
106
|
+
homepage: https://github.com/lann/rexpro-ruby
|
102
107
|
licenses:
|
103
108
|
- MIT
|
109
|
+
metadata: {}
|
104
110
|
post_install_message:
|
105
111
|
rdoc_options: []
|
106
112
|
require_paths:
|
107
113
|
- lib
|
108
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
115
|
requirements:
|
111
|
-
- -
|
116
|
+
- - '>='
|
112
117
|
- !ruby/object:Gem::Version
|
113
118
|
version: '0'
|
114
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
120
|
requirements:
|
117
|
-
- -
|
121
|
+
- - '>='
|
118
122
|
- !ruby/object:Gem::Version
|
119
123
|
version: '0'
|
120
124
|
requirements: []
|
121
125
|
rubyforge_project:
|
122
|
-
rubygems_version:
|
126
|
+
rubygems_version: 2.0.0
|
123
127
|
signing_key:
|
124
|
-
specification_version:
|
128
|
+
specification_version: 4
|
125
129
|
summary: RexPro is a binary protocol for Rexster that can be used to send Gremlin
|
126
130
|
scripts to a remote Rexster instance.
|
127
131
|
test_files:
|