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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d65c2ee6760cec8fc521979b62cda83acc9ffe0ff2c5f0d190b9afcf6923aa7
4
- data.tar.gz: 54199c67bc880e059ad3280956b7b628969e91a4e7fd43838ad23c9bf5334c34
3
+ metadata.gz: f25d2880441e748a0152d2f23afa956891bde3fd90e9c15886e21784ef0da61b
4
+ data.tar.gz: 82edb2e592d1fd45f895290d49f5f7d6533193e2406d7eadae89d0344082f986
5
5
  SHA512:
6
- metadata.gz: eecc477146f649aabf6ef8aae6a3c52391f2afba6ab37b495446b5cb5c0e2cd503247327e99e7e03ed4f624f5dca857bc0caf71cdd042a108ef426c412695e7d
7
- data.tar.gz: 39489c64659ef01d68b8d9920a366a9a46031e40a7aa65cb385b91a315ece2c949a7aa2cb0fcf10e12e90bc9dbca5f106a0bf0c140eb9cdac937faba8076d48d
6
+ metadata.gz: 29f37f4671b277a5b276f43bd4549a998f0ca17fbd80cfd41128d98e84fa9d64d594cfd271600e27f5fa9d20d0f33dab08c7c378790921143d5a0cf6441a9d2f
7
+ data.tar.gz: d2012cb64c0336afbfdf7e15b18f38295f35f1d4c88da068ce73abf8743bd672a800f984962040c70c9f6c64b65bbfc5d3e09a5eb881c60e5c714894ee019d2e
@@ -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
@@ -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
@@ -40,6 +40,7 @@ require 'active_support/core_ext/array/grouping'
40
40
  require 'concurrent/atomic/atomic_boolean'
41
41
  require 'concurrent/atomic/atomic_reference'
42
42
  require 'ffi'
43
+ require 'fiddle'
43
44
  require 'loader'
44
45
  require 'recursive-open-struct'
45
46
 
@@ -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
- config = Bolt::Config.create
23
- Bolt::Config.set_user_agent(config, 'seabolt-cmake/1.7')
24
- Bolt::Connector.create(address, auth_token, config)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neo4j
4
4
  module Driver
5
- VERSION = '0.1.8'
5
+ VERSION = '0.1.9'
6
6
  end
7
7
  end
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.8
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-18 00:00:00.000000000 Z
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