neo4j-ruby-driver 0.3.4 → 1.7.0
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/README.md +5 -6
- data/ffi/neo4j/driver.rb +4 -0
- data/ffi/neo4j/driver/graph_database.rb +1 -1
- data/ffi/neo4j/driver/internal/async/direct_connection.rb +17 -0
- data/ffi/neo4j/driver/internal/driver_factory.rb +1 -1
- data/ffi/neo4j/driver/internal/handlers/run_response_handler.rb +1 -1
- data/ffi/neo4j/driver/internal/internal_record.rb +6 -2
- data/ffi/neo4j/driver/internal/network_session.rb +16 -12
- data/ffi/neo4j/driver/types/entity.rb +4 -0
- data/lib/neo4j/driver/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d33153e299b755a419d12e6977650124965789923b7faedaddfa78dfde1bd6d1
|
4
|
+
data.tar.gz: abdaeef0e7c8dc83c6dc38d052e10630836a0cb3c9999976f8a1fed5b616a650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72296857ec72dd8d624098be60d5567a775fcbd4a0d3c6fcc931314072114c7ffcc8d33ac1a4f72dd8983ec9548d5da88609d7e1319b3223cc7450459f8e13c
|
7
|
+
data.tar.gz: e9a45e37d1332e0391230900949891945ee5e1182c89d6b63d87fe5992659fa14f2ef4bd6bfe80c42c2aa3daaa620013fbbef273141070341c78beccd8a37e34
|
data/README.md
CHANGED
@@ -72,12 +72,11 @@ FFI based same as above but with driver variable set:
|
|
72
72
|
To run the tests the following tools need to be installed:
|
73
73
|
|
74
74
|
$ brew install python
|
75
|
-
$
|
76
|
-
$
|
77
|
-
$ neoctrl-
|
78
|
-
$ neoctrl-
|
79
|
-
$ neoctrl-
|
80
|
-
$ neoctrl-start servers/neo4j-enterprise-4.0.0
|
75
|
+
$ pip3 install --user git+https://github.com/klobuczek/boltkit@1.3#egg=boltkit
|
76
|
+
$ neoctrl-install -e 4.0.2 servers
|
77
|
+
$ neoctrl-configure servers/neo4j-enterprise-4.0.2 dbms.directories.import= dbms.default_listen_address=::
|
78
|
+
$ neoctrl-set-initial-password password servers/neo4j-enterprise-4.0.2
|
79
|
+
$ neoctrl-start servers/neo4j-enterprise-4.0.2
|
81
80
|
|
82
81
|
## Contributing
|
83
82
|
|
data/ffi/neo4j/driver.rb
CHANGED
@@ -54,3 +54,7 @@ module Neo4j
|
|
54
54
|
end
|
55
55
|
|
56
56
|
Loader.load
|
57
|
+
|
58
|
+
Neo4j::Driver::Record = Neo4j::Driver::Internal::InternalRecord
|
59
|
+
Neo4j::Driver::StatementResult = Neo4j::Driver::Internal::InternalStatementResult
|
60
|
+
Neo4j::Driver::Transaction = Neo4j::Driver::Internal::ExplicitTransaction
|
@@ -44,7 +44,7 @@ module Neo4j
|
|
44
44
|
scheme = (uris.map(&method(:URI)).map(&:scheme) - VALID_ROUTING_SCHEMES).first
|
45
45
|
return unless scheme
|
46
46
|
raise ArgumentError,
|
47
|
-
"Illegal URI scheme, expected URI scheme '#{scheme}' to be among [#{VALID_ROUTING_SCHEMES.join ', '}]"
|
47
|
+
"Illegal URI scheme, expected URI scheme '#{scheme}' to be among '[#{VALID_ROUTING_SCHEMES.join ', '}]'"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -30,6 +30,7 @@ module Neo4j
|
|
30
30
|
)
|
31
31
|
end
|
32
32
|
set_bookmarks(:set_run_bookmarks, boomarks_holder.bookmarks)
|
33
|
+
set_config(:set_run, config)
|
33
34
|
register(run_handler, Bolt::Connection.load_run_request(bolt_connection))
|
34
35
|
register(pull_handler, Bolt::Connection.load_pull_request(bolt_connection, -1))
|
35
36
|
flush
|
@@ -42,6 +43,7 @@ module Neo4j
|
|
42
43
|
def begin(bookmarks, config, begin_handler)
|
43
44
|
check_error Bolt::Connection.clear_begin(bolt_connection)
|
44
45
|
set_bookmarks(:set_begin_bookmarks, bookmarks)
|
46
|
+
set_config(:set_begin, config)
|
45
47
|
register(begin_handler, Bolt::Connection.load_begin_request(bolt_connection))
|
46
48
|
end
|
47
49
|
|
@@ -82,6 +84,21 @@ module Neo4j
|
|
82
84
|
Value::ValueAdapter.to_neo(value, bookmarks)
|
83
85
|
check_error Bolt::Connection.send(method, bolt_connection, value)
|
84
86
|
end
|
87
|
+
|
88
|
+
def set_config(method_prefix, config)
|
89
|
+
return unless config
|
90
|
+
config.each do |key, value|
|
91
|
+
case key
|
92
|
+
when :timeout
|
93
|
+
check_error Bolt::Connection.send("#{method_prefix}_tx_timeout", bolt_connection,
|
94
|
+
DurationNormalizer.milliseconds(value))
|
95
|
+
when :metadata
|
96
|
+
bolt_value = Bolt::Value.create
|
97
|
+
Value::ValueAdapter.to_neo(bolt_value, value)
|
98
|
+
check_error Bolt::Connection.send("#{method_prefix}_tx_metadata", bolt_connection, bolt_value)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
85
102
|
end
|
86
103
|
end
|
87
104
|
end
|
@@ -21,7 +21,7 @@ module Neo4j
|
|
21
21
|
def finalize
|
22
22
|
return if @finished
|
23
23
|
super
|
24
|
-
@statement_keys = Value::ValueAdapter.to_ruby(Bolt::Connection.field_names(bolt_connection))
|
24
|
+
@statement_keys = Value::ValueAdapter.to_ruby(Bolt::Connection.field_names(bolt_connection)).map(&:to_sym)
|
25
25
|
metadata = Value::ValueAdapter.to_ruby(Bolt::Connection.metadata(bolt_connection))
|
26
26
|
@result_available_after = metadata[:result_available_after] || metadata[:t_first]
|
27
27
|
end
|
@@ -4,7 +4,7 @@ module Neo4j
|
|
4
4
|
module Driver
|
5
5
|
module Internal
|
6
6
|
class InternalRecord
|
7
|
-
attr_reader :values
|
7
|
+
attr_reader :keys, :values
|
8
8
|
delegate :first, to: :values
|
9
9
|
|
10
10
|
def initialize(keys, values)
|
@@ -13,9 +13,13 @@ module Neo4j
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def [](key)
|
16
|
-
field_index = key.is_a?(Integer) ? key : @keys.index(key.
|
16
|
+
field_index = key.is_a?(Integer) ? key : @keys.index(key.to_sym)
|
17
17
|
@values[field_index] if field_index
|
18
18
|
end
|
19
|
+
|
20
|
+
def to_h
|
21
|
+
keys.zip(values).to_h
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
@@ -18,7 +18,7 @@ module Neo4j
|
|
18
18
|
@retry_logic = retry_logic
|
19
19
|
end
|
20
20
|
|
21
|
-
def run(statement, parameters = {}, config =
|
21
|
+
def run(statement, parameters = {}, config = {})
|
22
22
|
ensure_session_is_open
|
23
23
|
ensure_no_open_tx_before_running_query
|
24
24
|
acquire_connection(@mode)
|
@@ -27,11 +27,11 @@ module Neo4j
|
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
30
|
-
def read_transaction(config
|
30
|
+
def read_transaction(**config, &block)
|
31
31
|
transaction(Neo4j::Driver::AccessMode::READ, config, &block)
|
32
32
|
end
|
33
33
|
|
34
|
-
def write_transaction(config
|
34
|
+
def write_transaction(**config, &block)
|
35
35
|
transaction(Neo4j::Driver::AccessMode::WRITE, config, &block)
|
36
36
|
end
|
37
37
|
|
@@ -49,11 +49,8 @@ module Neo4j
|
|
49
49
|
@connection&.release
|
50
50
|
end
|
51
51
|
|
52
|
-
def begin_transaction(
|
53
|
-
|
54
|
-
ensure_no_open_tx_before_starting_tx
|
55
|
-
acquire_connection(mode)
|
56
|
-
@transaction = ExplicitTransaction.new(@connection, self).begin(bookmarks, config)
|
52
|
+
def begin_transaction(**config)
|
53
|
+
private_begin_transaction(@mode, config)
|
57
54
|
end
|
58
55
|
|
59
56
|
def last_bookmark
|
@@ -66,9 +63,16 @@ module Neo4j
|
|
66
63
|
|
67
64
|
private
|
68
65
|
|
69
|
-
def
|
66
|
+
def private_begin_transaction(mode, config)
|
67
|
+
ensure_session_is_open
|
68
|
+
ensure_no_open_tx_before_starting_tx
|
69
|
+
acquire_connection(mode)
|
70
|
+
@transaction = ExplicitTransaction.new(@connection, self).begin(bookmarks, config)
|
71
|
+
end
|
72
|
+
|
73
|
+
def transaction(mode, config)
|
70
74
|
@retry_logic.retry do
|
71
|
-
tx =
|
75
|
+
tx = private_begin_transaction(mode, config)
|
72
76
|
result = yield tx
|
73
77
|
tx.success
|
74
78
|
result
|
@@ -80,7 +84,7 @@ module Neo4j
|
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
83
|
-
def acquire_connection(mode
|
87
|
+
def acquire_connection(mode)
|
84
88
|
# make sure previous result is fully consumed and connection is released back to the pool
|
85
89
|
@result&.failure
|
86
90
|
|
@@ -90,7 +94,7 @@ module Neo4j
|
|
90
94
|
# 3) previous result failed and error has been consumed
|
91
95
|
|
92
96
|
raise Exceptions::IllegalStateException, 'Existing open connection detected' if @connection&.open?
|
93
|
-
@connection = @connection_provider.acquire_connection(
|
97
|
+
@connection = @connection_provider.acquire_connection(mode)
|
94
98
|
end
|
95
99
|
|
96
100
|
def close_transaction_and_release_connection
|
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:
|
4
|
+
version: 1.7.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-
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|