neo4j-ruby-driver 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ffi/bolt/address_resolver.rb +12 -0
- data/ffi/bolt/address_set.rb +9 -0
- data/ffi/bolt/config.rb +4 -0
- data/ffi/bolt/log.rb +2 -2
- data/ffi/neo4j/driver/config.rb +15 -1
- data/ffi/neo4j/driver/graph_database.rb +1 -1
- data/ffi/neo4j/driver/internal/bolt_server_address.rb +18 -0
- data/ffi/neo4j/driver/internal/driver_factory.rb +11 -5
- data/ffi/neo4j/driver/internal/internal_driver.rb +5 -2
- data/ffi/neo4j/driver/internal/internal_resolver.rb +31 -0
- data/ffi/neo4j/driver/net/server_address.rb +13 -0
- data/ffi/neo4j/driver.rb +2 -0
- data/lib/neo4j/driver/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9da1a1a99dc073fdc74afd9078432f53d6d574eecf5fecc436c9207f9096687b
|
4
|
+
data.tar.gz: 0765c112017827121324658b302e4c7bd809fa7c390944aa21e912f16e371b9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf3e072bf5b7a189de7cb6f176c64f7d502e9e30f93590dcd4b35a1af0ac9c8d3e01f4e5d087269a9257f7e9995686e1d5cb4e258f46637e01ae53526cbec3ca
|
7
|
+
data.tar.gz: b3c9e897e362d1e93db0a82d554d8b1cb1dcc5f625b0fc3223214fd55295291eb41f40f1858aad32e0e61ab7a711dbbfcb1f3296e832ee5c33a81a551d44ce97
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bolt
|
4
|
+
module AddressResolver
|
5
|
+
extend Bolt::Library
|
6
|
+
|
7
|
+
callback :address_resolver_func, %i[pointer pointer pointer], :void
|
8
|
+
|
9
|
+
attach_function :create, :BoltAddressResolver_create, %i[pointer address_resolver_func], :auto_pointer
|
10
|
+
attach_function :destroy, :BoltLog_destroy, %i[pointer], :void
|
11
|
+
end
|
12
|
+
end
|
data/ffi/bolt/config.rb
CHANGED
data/ffi/bolt/log.rb
CHANGED
@@ -7,8 +7,8 @@ module Bolt
|
|
7
7
|
callback :log_func, %i[pointer string], :void
|
8
8
|
|
9
9
|
attach_function :create, :BoltLog_create, %i[pointer], :auto_pointer
|
10
|
-
attach_function :destroy, :
|
11
|
-
attach_function :set_error_func, :
|
10
|
+
attach_function :destroy, :BoltLog_destroy, %i[pointer], :void
|
11
|
+
attach_function :set_error_func, :BoltLog_set_error_func, %i[pointer log_func], :void
|
12
12
|
attach_function :set_warning_func, :BoltLog_set_warning_func, %i[pointer log_func], :void
|
13
13
|
attach_function :set_info_func, :BoltLog_set_info_func, %i[pointer log_func], :void
|
14
14
|
attach_function :set_debug_func, :BoltLog_set_debug_func, %i[pointer log_func], :void
|
data/ffi/neo4j/driver/config.rb
CHANGED
@@ -11,7 +11,21 @@ module Neo4j
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
def default_config
|
14
|
-
|
14
|
+
{
|
15
|
+
logger: ActiveSupport::Logger.new(STDOUT, level: ::Logger::ERROR), # :set_log
|
16
|
+
leaked_session_logging: false,
|
17
|
+
#connection_liveness_check_timeout: -1, # Not configured
|
18
|
+
max_connection_lifetime: 1.hour, # :set_max_connection_life_time
|
19
|
+
max_connection_pool_size: 100, #:set_max_pool_size
|
20
|
+
connection_acquisition_timeout: 1.minute, #:set_max_connection_acquisition_time
|
21
|
+
encryption: true, # :set_transport
|
22
|
+
trust_strategy: :trust_all_certificates,
|
23
|
+
connection_timeout: 30.seconds, # BoltSocketOptions_set_connect_timeout
|
24
|
+
max_transaction_retry_time: Internal::Retry::ExponentialBackoffRetryLogic::DEFAULT_MAX_RETRY_TIME,
|
25
|
+
#resolver: nil # :set_address_resolver
|
26
|
+
# ?????? BoltSocketOptions_set_keep_alive
|
27
|
+
# ???? BoltConfig_set_user_agent
|
28
|
+
}
|
15
29
|
end
|
16
30
|
end
|
17
31
|
end
|
@@ -21,7 +21,7 @@ module Neo4j
|
|
21
21
|
unless auth_token.is_a? FFI::Pointer
|
22
22
|
raise Exceptions::AuthenticationException, 'Unsupported authentication token'
|
23
23
|
end
|
24
|
-
config
|
24
|
+
config = Config.default_config.merge(config || {})
|
25
25
|
|
26
26
|
Internal::DriverFactory.new.new_instance(uri, auth_token, config)
|
27
27
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Neo4j
|
4
|
+
module Driver
|
5
|
+
module Internal
|
6
|
+
class BoltServerAddress
|
7
|
+
include Net::ServerAddress
|
8
|
+
|
9
|
+
attr_reader :host, :port
|
10
|
+
|
11
|
+
def initialize(host, port)
|
12
|
+
@host = host
|
13
|
+
@port = port
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -13,9 +13,9 @@ module Neo4j
|
|
13
13
|
def new_instance(uri, auth_token, config)
|
14
14
|
uri = URI(uri)
|
15
15
|
routing_context = routing_context(uri)
|
16
|
-
connector, logger = create_connector(uri, auth_token, routing_context, config)
|
16
|
+
connector, logger, resolver = create_connector(uri, auth_token, routing_context, config)
|
17
17
|
retry_logic = Retry::ExponentialBackoffRetryLogic.new(config[:max_transaction_retry_time], config[:logger])
|
18
|
-
create_driver(connector, logger, retry_logic, config).tap(&:verify_connectivity)
|
18
|
+
create_driver(connector, logger, resolver, retry_logic, config).tap(&:verify_connectivity)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -27,7 +27,8 @@ module Neo4j
|
|
27
27
|
set_socket_options(bolt_config, config)
|
28
28
|
set_routing_context(bolt_config, routing_context)
|
29
29
|
set_scheme(bolt_config, uri, routing_context)
|
30
|
-
|
30
|
+
resolver = InternalResolver.register(bolt_config, config[:resolver])
|
31
|
+
[Bolt::Connector.create(address, auth_token, bolt_config), logger, resolver]
|
31
32
|
end
|
32
33
|
|
33
34
|
def bolt_config(config)
|
@@ -41,6 +42,11 @@ module Neo4j
|
|
41
42
|
when :connection_acquisition_timeout
|
42
43
|
check_error Bolt::Config.set_max_connection_acquisition_time(bolt_config,
|
43
44
|
DurationNormalizer.milliseconds(value))
|
45
|
+
when :encryption
|
46
|
+
check_error Bolt::Config.set_transport(
|
47
|
+
bolt_config,
|
48
|
+
value ? Bolt::Config::BOLT_TRANSPORT_ENCRYPTED : Bolt::Config::BOLT_TRANSPORT_PLAINTEXT
|
49
|
+
)
|
44
50
|
end
|
45
51
|
end
|
46
52
|
check_error Bolt::Config.set_user_agent(bolt_config, 'seabolt-cmake/1.7')
|
@@ -102,10 +108,10 @@ module Neo4j
|
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
105
|
-
def create_driver(connector, logger, retry_logic, config)
|
111
|
+
def create_driver(connector, logger, resolver, retry_logic, config)
|
106
112
|
connection_provider = DirectConnectionProvider.new(connector, config)
|
107
113
|
session_factory = create_session_factory(connection_provider, retry_logic, config)
|
108
|
-
InternalDriver.new(session_factory, logger)
|
114
|
+
InternalDriver.new(session_factory, logger, resolver)
|
109
115
|
end
|
110
116
|
|
111
117
|
def create_session_factory(connection_provider, retry_logic = nil, config = nil)
|
@@ -11,10 +11,13 @@ module Neo4j
|
|
11
11
|
delegate :verify_connectivity, to: :session_factory
|
12
12
|
auto_closable :session
|
13
13
|
|
14
|
-
def initialize(session_factory, logger)
|
14
|
+
def initialize(session_factory, logger, resolver)
|
15
15
|
@session_factory = session_factory
|
16
|
-
@logger = logger # just a weak reference to prevent garbage collection
|
17
16
|
@closed = Concurrent::AtomicBoolean.new(false)
|
17
|
+
# The below hold references to callbacks called from c,
|
18
|
+
# this prevents garbage collection before driver is garbage collected
|
19
|
+
@logger = logger
|
20
|
+
@resolver = resolver
|
18
21
|
end
|
19
22
|
|
20
23
|
def session(*args)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Neo4j
|
4
|
+
module Driver
|
5
|
+
module Internal
|
6
|
+
class InternalResolver
|
7
|
+
include ErrorHandling
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def register(bolt_config, resolver)
|
11
|
+
return unless resolver
|
12
|
+
new(bolt_config, resolver)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(bolt_config, resolver)
|
17
|
+
@address_resolver_func = ->(_ptr, address, set) {
|
18
|
+
resolver.call(BoltServerAddress.new(Bolt::Address.host(address).first,
|
19
|
+
Bolt::Address.port(address).first.to_i)).each do |server_address|
|
20
|
+
bolt_address = Bolt::Address.create(server_address.host, server_address.port.to_s)
|
21
|
+
check_error Bolt::AddressSet.add(set, bolt_address)
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
address_resolver = Bolt::AddressResolver.create(nil, @address_resolver_func)
|
26
|
+
check_error Bolt::Config.set_address_resolver(bolt_config, address_resolver)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/ffi/neo4j/driver.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heinrich Klobuczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -224,6 +224,8 @@ files:
|
|
224
224
|
- LICENSE.txt
|
225
225
|
- README.md
|
226
226
|
- ffi/bolt/address.rb
|
227
|
+
- ffi/bolt/address_resolver.rb
|
228
|
+
- ffi/bolt/address_set.rb
|
227
229
|
- ffi/bolt/auth.rb
|
228
230
|
- ffi/bolt/auto_releasable.rb
|
229
231
|
- ffi/bolt/boolean.rb
|
@@ -251,6 +253,7 @@ files:
|
|
251
253
|
- ffi/neo4j/driver/graph_database.rb
|
252
254
|
- ffi/neo4j/driver/internal/async/access_mode_connection.rb
|
253
255
|
- ffi/neo4j/driver/internal/async/direct_connection.rb
|
256
|
+
- ffi/neo4j/driver/internal/bolt_server_address.rb
|
254
257
|
- ffi/neo4j/driver/internal/bookmarks_holder.rb
|
255
258
|
- ffi/neo4j/driver/internal/direct_connection_provider.rb
|
256
259
|
- ffi/neo4j/driver/internal/driver_factory.rb
|
@@ -264,6 +267,7 @@ files:
|
|
264
267
|
- ffi/neo4j/driver/internal/internal_driver.rb
|
265
268
|
- ffi/neo4j/driver/internal/internal_logger.rb
|
266
269
|
- ffi/neo4j/driver/internal/internal_record.rb
|
270
|
+
- ffi/neo4j/driver/internal/internal_resolver.rb
|
267
271
|
- ffi/neo4j/driver/internal/internal_statement_result.rb
|
268
272
|
- ffi/neo4j/driver/internal/messaging/bolt_protocol.rb
|
269
273
|
- ffi/neo4j/driver/internal/messaging/v1/bolt_protocol_v1.rb
|
@@ -292,6 +296,7 @@ files:
|
|
292
296
|
- ffi/neo4j/driver/internal/value/time_with_zone_offset_value.rb
|
293
297
|
- ffi/neo4j/driver/internal/value/unbound_relationship_value.rb
|
294
298
|
- ffi/neo4j/driver/internal/value/value_adapter.rb
|
299
|
+
- ffi/neo4j/driver/net/server_address.rb
|
295
300
|
- ffi/neo4j/driver/statement.rb
|
296
301
|
- ffi/neo4j/driver/summary/statement_type.rb
|
297
302
|
- ffi/neo4j/driver/types/entity.rb
|