orientdb_client 0.0.7 → 0.0.8
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -0
- data/Gemfiles/Gemfile.as3.2 +1 -0
- data/Gemfiles/Gemfile.as4.0 +1 -0
- data/Gemfiles/Gemfile.as5.0 +1 -0
- data/LICENSE.txt +18 -1
- data/README.md +15 -0
- data/lib/orientdb_client.rb +5 -3
- data/lib/orientdb_client/errors.rb +1 -0
- data/lib/orientdb_client/integration/skylight_normalizer.rb +34 -0
- data/lib/orientdb_client/version.rb +1 -1
- data/spec/orientdb_client_spec.rb +3 -3
- data/spec/skylight_normalizer_spec.rb +84 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/skylight_tracing.rb +15 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ff9bea3763a8ec608f82345d72cf055701c520
|
4
|
+
data.tar.gz: f87c97ac3b85eee009e16c28694c5ddbcad9af49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4be54bafd6bbab818aa34f4f29b73468e620bd07a5c93bd32dc3e6c92d8d9dcd75b03644dbe4a5649a04544fc494113c35def34dadff55a8f4a3327e5ae215fb
|
7
|
+
data.tar.gz: 4028fbaa72f17074eff9a2588cc9f44a9824e6f0f94eda236984abcc8f55b1ad67c6354f8d91803c6a6d88723e96924b5a5e2d3ab47e25619e86d48ddd760671
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfiles/Gemfile.as3.2
CHANGED
data/Gemfiles/Gemfile.as4.0
CHANGED
data/Gemfiles/Gemfile.as5.0
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2015 Luke Rodgers
|
1
|
+
Copyright (c) 2015-2016 Luke Rodgers
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -20,3 +20,20 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
|
25
|
+
## Other Licenses
|
26
|
+
|
27
|
+
### Ruby on Rails
|
28
|
+
|
29
|
+
Copyright (c) 2005-2016 David Heinemeier Hansson
|
30
|
+
|
31
|
+
Released under the MIT License.
|
32
|
+
|
33
|
+
Original source at https://github.com/rails/rails.
|
34
|
+
|
35
|
+
### Skylight
|
36
|
+
|
37
|
+
Copyright (c) 2013-2016 Tilde, Inc.
|
38
|
+
|
39
|
+
Original source at https://github.com/skylightio/skylight-ruby
|
data/README.md
CHANGED
@@ -12,6 +12,7 @@ Goals:
|
|
12
12
|
* fine-grained handling of Orientdb errors, via rich set of ruby exceptions
|
13
13
|
|
14
14
|
Tested on:
|
15
|
+
* 2.2.10
|
15
16
|
* 2.1.10
|
16
17
|
* 2.1.9
|
17
18
|
* 2.1.5
|
@@ -91,6 +92,20 @@ The following events are instrumented:
|
|
91
92
|
* `process_response.orientdb_client`: most of this will correspond to JSON parsing
|
92
93
|
and error response code/message handling.
|
93
94
|
|
95
|
+
### Skylight.io integration
|
96
|
+
|
97
|
+
If you use Skylight for application monitoring, you can include an OrientDB normalizer so that Skylight will group
|
98
|
+
your OrientDB queries with other db (sql, redis) queries and visually separate them from the rest of your rails code.
|
99
|
+
|
100
|
+
The best way I've found to do this is including this in your `config/application.rb`:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
config.before_initialize do
|
104
|
+
# This will run before initializers for all railties, which is where Skylight registers its normalizers.
|
105
|
+
require 'orientdb_client/integration/skylight_normalizer'
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
94
109
|
## HTTP Adapters
|
95
110
|
|
96
111
|
OrientdbClient currently supports Typhoeus and Curb HTTP adapters.
|
data/lib/orientdb_client.rb
CHANGED
@@ -140,7 +140,7 @@ module OrientdbClient
|
|
140
140
|
attr_reader :database
|
141
141
|
attr_writer :debug
|
142
142
|
|
143
|
-
def initialize(host:, port:, http_client
|
143
|
+
def initialize(host:, port:, http_client:, client:)
|
144
144
|
@host = host
|
145
145
|
@port = port
|
146
146
|
@http_client = http_client
|
@@ -276,6 +276,8 @@ module OrientdbClient
|
|
276
276
|
raise ConnectionError.new("No server at #{@host}:#{@port}", 0, nil)
|
277
277
|
when 200, 201, 204
|
278
278
|
return response
|
279
|
+
when 400
|
280
|
+
translate_error(response)
|
279
281
|
when 401
|
280
282
|
raise UnauthorizedError.new('Unauthorized', response.response_code, response.body)
|
281
283
|
when 404
|
@@ -307,8 +309,8 @@ module OrientdbClient
|
|
307
309
|
code = response.response_code
|
308
310
|
body = response.body
|
309
311
|
case odb_error_class
|
310
|
-
when /OCommandSQLParsingException
|
311
|
-
raise
|
312
|
+
when /OCommandSQLParsingException/, "Error parsing query", "Error on parsing command"
|
313
|
+
raise ParsingError.new("#{odb_error_class}: #{odb_error_message}", code, body)
|
312
314
|
when /OQueryParsingException/
|
313
315
|
raise ClientError.new("#{odb_error_class}: #{odb_error_message}", code, body)
|
314
316
|
when /OCommandExecutorNotFoundException/
|
@@ -28,6 +28,7 @@ module OrientdbClient
|
|
28
28
|
class IllegalArgumentException < ClientError; end
|
29
29
|
class CommandExecutionException < ClientError; end
|
30
30
|
class SerializationException < ClientError; end
|
31
|
+
class ParsingError < ClientError; end
|
31
32
|
|
32
33
|
# ConflictError: you tried to create something that already exists
|
33
34
|
class ConflictError < ClientError; end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'skylight'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Skylight
|
5
|
+
module Normalizers
|
6
|
+
module OrientdbClient
|
7
|
+
class Query < Normalizer
|
8
|
+
register "request.orientdb_client"
|
9
|
+
|
10
|
+
CAT = "db.orientdb.query".freeze
|
11
|
+
QUERY_REGEX = /\/([^\/]+)/
|
12
|
+
SUPPORTED_QUERY_TYPES = ["query".freeze, "command".freeze]
|
13
|
+
|
14
|
+
def normalize(trace, name, payload)
|
15
|
+
url = payload[:url]
|
16
|
+
query_type = nil
|
17
|
+
begin
|
18
|
+
uri = URI.parse(url)
|
19
|
+
match = uri.path.match(QUERY_REGEX)
|
20
|
+
if match
|
21
|
+
query_type = match[1]
|
22
|
+
end
|
23
|
+
rescue URI::Error
|
24
|
+
return :skip
|
25
|
+
end
|
26
|
+
|
27
|
+
return :skip unless SUPPORTED_QUERY_TYPES.include?(query_type)
|
28
|
+
|
29
|
+
[ CAT, "orientdb: #{query_type}", nil ]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -206,7 +206,7 @@ RSpec.describe OrientdbClient do
|
|
206
206
|
|
207
207
|
context 'with invalid query' do
|
208
208
|
it 'raises ClientError' do
|
209
|
-
expect { client.query('select * crumb') }.to raise_exception(OrientdbClient::
|
209
|
+
expect { client.query('select * crumb') }.to raise_exception(OrientdbClient::ParsingError)
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
@@ -255,7 +255,7 @@ RSpec.describe OrientdbClient do
|
|
255
255
|
|
256
256
|
context 'with invalid query' do
|
257
257
|
it 'returns result' do
|
258
|
-
expect { client.command('select * crumb') }.to raise_exception(OrientdbClient::
|
258
|
+
expect { client.command('select * crumb') }.to raise_exception(OrientdbClient::ParsingError)
|
259
259
|
end
|
260
260
|
end
|
261
261
|
end
|
@@ -511,7 +511,7 @@ RSpec.describe OrientdbClient do
|
|
511
511
|
it 'raises exception on creation of classes that extend nothing' do
|
512
512
|
expect do
|
513
513
|
client.create_class(class_name, extends: 'VJk')
|
514
|
-
end.to raise_exception(OrientdbClient::
|
514
|
+
end.to raise_exception(OrientdbClient::ParsingError)
|
515
515
|
end
|
516
516
|
|
517
517
|
describe 'with block' do
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'orientdb_client/integration/skylight_normalizer'
|
5
|
+
|
6
|
+
RSpec.describe Skylight::Normalizers::OrientdbClient::Query do
|
7
|
+
|
8
|
+
let(:n) { Skylight::Normalizers::OrientdbClient::Query.new({}) }
|
9
|
+
let(:name) { 'odb_query' }
|
10
|
+
|
11
|
+
it 'normalizes a graph query' do
|
12
|
+
name, title, desc = n.normalize(trace, name, url: 'http://localhost:2480/query/graphdb/sql/select+%2A+from+Post+order+by+%40rid+desc+limit+1')
|
13
|
+
expect(name).to eql('db.orientdb.query')
|
14
|
+
expect(title).to eql('orientdb: query')
|
15
|
+
expect(desc).to be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'normalizes a graph query without a title' do
|
19
|
+
name, title, desc = n.normalize(trace, nil, url: 'http://localhost:2480/query/graphdb/sql/select+%2A+from+Post+order+by+%40rid+desc+limit+1')
|
20
|
+
expect(name).to eql('db.orientdb.query')
|
21
|
+
expect(title).to eql('orientdb: query')
|
22
|
+
expect(desc).to be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'normalizes a graph query with multibyte characaters' do
|
26
|
+
name, title, desc = n.normalize(trace, nil, url: 'http://localhost:2480/query/graphdb/sql/select+%2A+from+Post+where+name+%3D+%22%F0%9D%92%9C+FROM+z%C3%B8mg+%C3%A5%22')
|
27
|
+
expect(name).to eql('db.orientdb.query')
|
28
|
+
expect(title).to eql('orientdb: query')
|
29
|
+
expect(desc).to be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'normalizes a graph update with JSON in URL' do
|
33
|
+
name, title, desc = n.normalize(trace, name, url: 'http://localhost:2480/command/graphdb/sql/update+%2311%3A2+set+category_list%3D%5B%22sports%22%2C+%22gaming%22%2C+%22music%22%5D')
|
34
|
+
expect(name).to eql('db.orientdb.query')
|
35
|
+
expect(title).to eql('orientdb: command')
|
36
|
+
expect(desc).to be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'normalizes property creation commands' do
|
40
|
+
name, title, desc = n.normalize(trace, name, url: 'http://localhost:2480/command/graphdb/sql/CREATE+PROPERTY+Post.id+string')
|
41
|
+
expect(name).to eql('db.orientdb.query')
|
42
|
+
expect(title).to eql('orientdb: command')
|
43
|
+
expect(desc).to be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'normalizes property alter commands' do
|
47
|
+
name, title, desc = n.normalize(trace, name, url: 'http://localhost:2480/command/graphdb/sql/ALTER+PROPERTY+Post.exists+type+integer')
|
48
|
+
expect(name).to eql('db.orientdb.query')
|
49
|
+
expect(title).to eql('orientdb: command')
|
50
|
+
expect(desc).to be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'normalizes class creation commands' do
|
54
|
+
name, title, desc = n.normalize(trace, name, url: 'http://localhost:2480/command/graphdb/sql/CREATE+CLASS+Post')
|
55
|
+
expect(name).to eql('db.orientdb.query')
|
56
|
+
expect(title).to eql('orientdb: command')
|
57
|
+
expect(desc).to be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'skips connect queries' do
|
61
|
+
name, * = n.normalize(trace, name, url: 'http://localhost:2480/connect/graphdb')
|
62
|
+
expect(name).to eql(:skip)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'skips disconnect queries' do
|
66
|
+
name, * = n.normalize(trace, name, url: 'http://localhost:2480/disconnect')
|
67
|
+
expect(name).to eql(:skip)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'skips listDatabase queries' do
|
71
|
+
name, * = n.normalize(trace, name, url: 'http://localhost:2480/listDatabases')
|
72
|
+
expect(name).to eql(:skip)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'skips database creation' do
|
76
|
+
name, * = n.normalize(trace, name, url: 'http://localhost:2480/database/foobaz/plocal/graph')
|
77
|
+
expect(name).to eql(:skip)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'skips unknown queries' do
|
81
|
+
name, * = n.normalize(trace, name, url: 'http://localhost:2480/cluster/unknownop?x=y')
|
82
|
+
expect(name).to eql(:skip)
|
83
|
+
end
|
84
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -39,6 +39,11 @@ ensure
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
# Require support files
|
43
|
+
Dir[File.expand_path('../support/*.rb', __FILE__)].each do |f|
|
44
|
+
require "support/#{File.basename(f, ".rb")}"
|
45
|
+
end
|
46
|
+
|
42
47
|
RSpec.configure do |config|
|
43
48
|
# rspec-expectations config goes here. You can use an alternate
|
44
49
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
@@ -68,6 +73,8 @@ RSpec.configure do |config|
|
|
68
73
|
config.order = :random
|
69
74
|
Kernel.srand config.seed
|
70
75
|
|
76
|
+
config.include SpecHelper
|
77
|
+
|
71
78
|
# The settings below are suggested to provide a good initial experience
|
72
79
|
# with RSpec, but feel free to customize to your heart's content.
|
73
80
|
=begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orientdb_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Rodgers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -150,14 +150,17 @@ files:
|
|
150
150
|
- lib/orientdb_client/instrumentation/log_subscriber.rb
|
151
151
|
- lib/orientdb_client/instrumenters/memory.rb
|
152
152
|
- lib/orientdb_client/instrumenters/noop.rb
|
153
|
+
- lib/orientdb_client/integration/skylight_normalizer.rb
|
153
154
|
- lib/orientdb_client/test.rb
|
154
155
|
- lib/orientdb_client/version.rb
|
155
156
|
- orientdb_client.gemspec
|
156
157
|
- spec/curb_adapter_spec.rb
|
157
158
|
- spec/integration/orientdb_client/instrumentation/log_subscriber_spec.rb
|
158
159
|
- spec/orientdb_client_spec.rb
|
160
|
+
- spec/skylight_normalizer_spec.rb
|
159
161
|
- spec/spec_helper.rb
|
160
162
|
- spec/support/shared_examples_for_http_adapter.rb
|
163
|
+
- spec/support/skylight_tracing.rb
|
161
164
|
- spec/typhoeus_adapter_spec.rb
|
162
165
|
homepage: https://github.com/lukeasrodgers/orientdb_client
|
163
166
|
licenses:
|
@@ -187,6 +190,8 @@ test_files:
|
|
187
190
|
- spec/curb_adapter_spec.rb
|
188
191
|
- spec/integration/orientdb_client/instrumentation/log_subscriber_spec.rb
|
189
192
|
- spec/orientdb_client_spec.rb
|
193
|
+
- spec/skylight_normalizer_spec.rb
|
190
194
|
- spec/spec_helper.rb
|
191
195
|
- spec/support/shared_examples_for_http_adapter.rb
|
196
|
+
- spec/support/skylight_tracing.rb
|
192
197
|
- spec/typhoeus_adapter_spec.rb
|