neo4j-ruby-driver 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ffi/bolt/config.rb +2 -0
- data/ffi/bolt/log.rb +16 -0
- data/ffi/neo4j/driver.rb +1 -0
- data/ffi/neo4j/driver/graph_database.rb +1 -1
- data/ffi/neo4j/driver/internal/driver_factory.rb +22 -11
- data/ffi/neo4j/driver/internal/internal_driver.rb +2 -1
- data/ffi/neo4j/driver/internal/internal_logger.rb +32 -0
- data/lib/neo4j/driver/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f25d2880441e748a0152d2f23afa956891bde3fd90e9c15886e21784ef0da61b
|
4
|
+
data.tar.gz: 82edb2e592d1fd45f895290d49f5f7d6533193e2406d7eadae89d0344082f986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f37f4671b277a5b276f43bd4549a998f0ca17fbd80cfd41128d98e84fa9d64d594cfd271600e27f5fa9d20d0f33dab08c7c378790921143d5a0cf6441a9d2f
|
7
|
+
data.tar.gz: d2012cb64c0336afbfdf7e15b18f38295f35f1d4c88da068ce73abf8743bd672a800f984962040c70c9f6c64b65bbfc5d3e09a5eb881c60e5c714894ee019d2e
|
data/ffi/bolt/config.rb
CHANGED
@@ -5,6 +5,8 @@ module Bolt
|
|
5
5
|
extend Bolt::Library
|
6
6
|
attach_function :create, :BoltConfig_create, [], :auto_pointer
|
7
7
|
attach_function :destroy, :BoltConfig_destroy, [:pointer], :void
|
8
|
+
attach_function :get_log, :BoltConfig_get_log, [:pointer], :pointer
|
9
|
+
attach_function :set_log, :BoltConfig_set_log, %i[pointer pointer], :int32
|
8
10
|
attach_function :set_user_agent, :BoltConfig_set_user_agent, %i[pointer string], :int32
|
9
11
|
end
|
10
12
|
end
|
data/ffi/bolt/log.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bolt
|
4
|
+
module Log
|
5
|
+
extend Bolt::Library
|
6
|
+
|
7
|
+
callback :log_func, %i[pointer string], :void
|
8
|
+
|
9
|
+
attach_function :create, :BoltLog_create, %i[pointer], :auto_pointer
|
10
|
+
attach_function :destroy, :BoltLog_create, %i[pointer], :void
|
11
|
+
attach_function :set_error_func, :BoltLog_create, %i[pointer log_func], :void
|
12
|
+
attach_function :set_warning_func, :BoltLog_set_warning_func, %i[pointer log_func], :void
|
13
|
+
attach_function :set_info_func, :BoltLog_set_info_func, %i[pointer log_func], :void
|
14
|
+
attach_function :set_debug_func, :BoltLog_set_debug_func, %i[pointer log_func], :void
|
15
|
+
end
|
16
|
+
end
|
data/ffi/neo4j/driver.rb
CHANGED
@@ -16,7 +16,7 @@ module Neo4j
|
|
16
16
|
|
17
17
|
def driver(uri, auth_token = Neo4j::Driver::AuthTokens.none, config = {})
|
18
18
|
raise Exceptions::AuthenticationException, 'Unsupported authentication token' unless auth_token
|
19
|
-
config ||= Config.default_config
|
19
|
+
# config ||= Config.default_config
|
20
20
|
# routing_settings = config.routing_settings
|
21
21
|
# retry_settings = config.retry_settings
|
22
22
|
routing_settings = nil
|
@@ -4,6 +4,7 @@ module Neo4j
|
|
4
4
|
module Driver
|
5
5
|
module Internal
|
6
6
|
class DriverFactory
|
7
|
+
include ErrorHandling
|
7
8
|
BOLT_URI_SCHEME = 'bolt'
|
8
9
|
BOLT_ROUTING_URI_SCHEME = 'bolt+routing'
|
9
10
|
NEO4J_URI_SCHEME = 'neo4j'
|
@@ -11,17 +12,27 @@ module Neo4j
|
|
11
12
|
|
12
13
|
def new_instance(uri, auth_token, routing_settings, retry_settings, config)
|
13
14
|
uri = URI(uri)
|
14
|
-
connector = create_connector(uri, auth_token)
|
15
|
-
create_driver(uri.scheme, connector, routing_settings).tap(&:verify_connectivity)
|
15
|
+
connector, logger = create_connector(uri, auth_token, config)
|
16
|
+
create_driver(uri.scheme, connector, logger, routing_settings).tap(&:verify_connectivity)
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
19
20
|
|
20
|
-
def create_connector(uri, auth_token)
|
21
|
+
def create_connector(uri, auth_token, config)
|
21
22
|
address = Bolt::Address.create(host(uri).gsub(/^\[(.*)\]$/, '\\1'), port(uri).to_s)
|
22
|
-
|
23
|
-
|
24
|
-
Bolt::Connector.create(address, auth_token,
|
23
|
+
bolt_config = bolt_config(config)
|
24
|
+
logger = InternalLogger.register(bolt_config, config[:logger])
|
25
|
+
[Bolt::Connector.create(address, auth_token, bolt_config), logger]
|
26
|
+
end
|
27
|
+
|
28
|
+
def bolt_config(config)
|
29
|
+
bolt_config = Bolt::Config.create
|
30
|
+
config.each do |key, value|
|
31
|
+
# case key
|
32
|
+
# end
|
33
|
+
end
|
34
|
+
check_error Bolt::Config.set_user_agent(bolt_config, 'seabolt-cmake/1.7')
|
35
|
+
bolt_config
|
25
36
|
end
|
26
37
|
|
27
38
|
def host(uri)
|
@@ -29,16 +40,16 @@ module Neo4j
|
|
29
40
|
end
|
30
41
|
|
31
42
|
def port(uri)
|
32
|
-
uri.port&.tap {|port| raise ArgumentError, "Illegal port: #{port}" unless (0..65_535).cover?(port) } ||
|
43
|
+
uri.port&.tap { |port| raise ArgumentError, "Illegal port: #{port}" unless (0..65_535).cover?(port) } ||
|
33
44
|
DEFAULT_PORT
|
34
45
|
end
|
35
46
|
|
36
|
-
def create_driver(scheme, connector, routing_settings)
|
47
|
+
def create_driver(scheme, connector, logger, routing_settings)
|
37
48
|
case scheme
|
38
49
|
when BOLT_URI_SCHEME
|
39
50
|
# assert_no_routing_context( uri, routing_settings )
|
40
51
|
# return createDirectDriver( securityPlan, address, connectionPool, retryLogic, metrics, config );
|
41
|
-
create_direct_driver(connector)
|
52
|
+
create_direct_driver(connector, logger)
|
42
53
|
when BOLT_ROUTING_URI_SCHEME, NEO4J_URI_SCHEME
|
43
54
|
# create_routing_driver( security_plan, address, connection_ool, eventExecutorGroup, routingSettings, retryLogic, metrics, config );
|
44
55
|
else
|
@@ -46,10 +57,10 @@ module Neo4j
|
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
49
|
-
def create_direct_driver(connector)
|
60
|
+
def create_direct_driver(connector, logger)
|
50
61
|
connection_provider = DirectConnectionProvider.new(connector)
|
51
62
|
session_factory = create_session_factory(connection_provider)
|
52
|
-
InternalDriver.new(session_factory)
|
63
|
+
InternalDriver.new(session_factory, logger)
|
53
64
|
end
|
54
65
|
|
55
66
|
def create_session_factory(connection_provider, retry_logic = nil, config = nil)
|
@@ -11,8 +11,9 @@ module Neo4j
|
|
11
11
|
delegate :verify_connectivity, to: :session_factory
|
12
12
|
auto_closable :session
|
13
13
|
|
14
|
-
def initialize(session_factory)
|
14
|
+
def initialize(session_factory, logger)
|
15
15
|
@session_factory = session_factory
|
16
|
+
@logger = logger # just a weak reference to prevent garbage collection
|
16
17
|
@closed = Concurrent::AtomicBoolean.new(false)
|
17
18
|
end
|
18
19
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Neo4j
|
4
|
+
module Driver
|
5
|
+
module Internal
|
6
|
+
class InternalLogger
|
7
|
+
include ErrorHandling
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def register(bolt_config, logger)
|
11
|
+
return unless logger
|
12
|
+
new(bolt_config, logger)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(bolt_config, logger)
|
17
|
+
@logger = logger
|
18
|
+
@funcs = []
|
19
|
+
bolt_log = Bolt::Log.create(nil)
|
20
|
+
%i[error warning info debug].each do |method|
|
21
|
+
Bolt::Log.send("set_#{method}_func", bolt_log, func(method))
|
22
|
+
end
|
23
|
+
check_error Bolt::Config.set_log(bolt_config, bolt_log)
|
24
|
+
end
|
25
|
+
|
26
|
+
def func(method)
|
27
|
+
Proc.new { |_ptr, message| @logger.send(method, message) }.tap(&@funcs.method(:<<))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/neo4j/driver/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-ruby-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heinrich Klobuczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- ffi/bolt/library.rb
|
239
239
|
- ffi/bolt/lifecycle.rb
|
240
240
|
- ffi/bolt/list.rb
|
241
|
+
- ffi/bolt/log.rb
|
241
242
|
- ffi/bolt/status.rb
|
242
243
|
- ffi/bolt/string.rb
|
243
244
|
- ffi/bolt/structure.rb
|
@@ -261,6 +262,7 @@ files:
|
|
261
262
|
- ffi/neo4j/driver/internal/handlers/session_pull_all_response_handler.rb
|
262
263
|
- ffi/neo4j/driver/internal/handlers/transaction_pull_all_response_handler.rb
|
263
264
|
- ffi/neo4j/driver/internal/internal_driver.rb
|
265
|
+
- ffi/neo4j/driver/internal/internal_logger.rb
|
264
266
|
- ffi/neo4j/driver/internal/internal_record.rb
|
265
267
|
- ffi/neo4j/driver/internal/internal_statement_result.rb
|
266
268
|
- ffi/neo4j/driver/internal/messaging/bolt_protocol.rb
|