neo4j-ruby-driver 4.4.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +72 -0
  4. data/jruby/neo4j/driver/ext/async_converter.rb +55 -0
  5. data/jruby/neo4j/driver/ext/auth_tokens.rb +20 -0
  6. data/jruby/neo4j/driver/ext/bookmark.rb +15 -0
  7. data/jruby/neo4j/driver/ext/config_converter.rb +69 -0
  8. data/jruby/neo4j/driver/ext/exception_checkable.rb +34 -0
  9. data/jruby/neo4j/driver/ext/exception_mapper.rb +89 -0
  10. data/jruby/neo4j/driver/ext/graph_database.rb +29 -0
  11. data/jruby/neo4j/driver/ext/internal/async/internal_async_session.rb +23 -0
  12. data/jruby/neo4j/driver/ext/internal/cluster/routing_table_registry_impl.rb +15 -0
  13. data/jruby/neo4j/driver/ext/internal/cursor/disposable_async_result_cursor.rb +15 -0
  14. data/jruby/neo4j/driver/ext/internal/metrics/internal_connection_pool_metrics.rb +17 -0
  15. data/jruby/neo4j/driver/ext/internal/summary/internal_result_summary.rb +32 -0
  16. data/jruby/neo4j/driver/ext/internal_driver.rb +34 -0
  17. data/jruby/neo4j/driver/ext/internal_entity.rb +21 -0
  18. data/jruby/neo4j/driver/ext/internal_keys.rb +15 -0
  19. data/jruby/neo4j/driver/ext/internal_node.rb +13 -0
  20. data/jruby/neo4j/driver/ext/internal_record.rb +29 -0
  21. data/jruby/neo4j/driver/ext/internal_relationship.rb +13 -0
  22. data/jruby/neo4j/driver/ext/internal_result.rb +23 -0
  23. data/jruby/neo4j/driver/ext/internal_session.rb +40 -0
  24. data/jruby/neo4j/driver/ext/internal_transaction.rb +24 -0
  25. data/jruby/neo4j/driver/ext/logger.rb +60 -0
  26. data/jruby/neo4j/driver/ext/map_converter.rb +14 -0
  27. data/jruby/neo4j/driver/ext/neo_converter.rb +59 -0
  28. data/jruby/neo4j/driver/ext/query.rb +13 -0
  29. data/jruby/neo4j/driver/ext/ruby_converter.rb +57 -0
  30. data/jruby/neo4j/driver/ext/run_override.rb +22 -0
  31. data/jruby/neo4j/driver/ext/start_end_naming.rb +17 -0
  32. data/jruby/neo4j/driver.rb +54 -0
  33. data/lib/loader.rb +19 -0
  34. data/lib/neo4j/driver/auto_closable.rb +32 -0
  35. data/lib/neo4j/driver/exceptions/authentication_exception.rb +15 -0
  36. data/lib/neo4j/driver/exceptions/authorization_expired_exception.rb +14 -0
  37. data/lib/neo4j/driver/exceptions/certificate_exception.rb +10 -0
  38. data/lib/neo4j/driver/exceptions/client_exception.rb +18 -0
  39. data/lib/neo4j/driver/exceptions/connection_read_timeout_exception.rb +14 -0
  40. data/lib/neo4j/driver/exceptions/database_exception.rb +13 -0
  41. data/lib/neo4j/driver/exceptions/discovery_exception.rb +16 -0
  42. data/lib/neo4j/driver/exceptions/fatal_discovery_exception.rb +13 -0
  43. data/lib/neo4j/driver/exceptions/illegal_state_exception.rb +10 -0
  44. data/lib/neo4j/driver/exceptions/neo4j_exception.rb +22 -0
  45. data/lib/neo4j/driver/exceptions/no_such_record_exception.rb +33 -0
  46. data/lib/neo4j/driver/exceptions/protocol_exception.rb +17 -0
  47. data/lib/neo4j/driver/exceptions/result_consumed_exception.rb +13 -0
  48. data/lib/neo4j/driver/exceptions/security_exception.rb +14 -0
  49. data/lib/neo4j/driver/exceptions/service_unavailable_exception.rb +12 -0
  50. data/lib/neo4j/driver/exceptions/session_expired_exception.rb +14 -0
  51. data/lib/neo4j/driver/exceptions/token_expired_exception.rb +15 -0
  52. data/lib/neo4j/driver/exceptions/transaction_nesting_exception.rb +11 -0
  53. data/lib/neo4j/driver/exceptions/transient_exception.rb +13 -0
  54. data/lib/neo4j/driver/exceptions/untrusted_server_exception.rb +11 -0
  55. data/lib/neo4j/driver/exceptions/value/lossy_coercion.rb +15 -0
  56. data/lib/neo4j/driver/exceptions/value/not_multi_valued.rb +13 -0
  57. data/lib/neo4j/driver/exceptions/value/uncoercible.rb +15 -0
  58. data/lib/neo4j/driver/exceptions/value/unsizable.rb +12 -0
  59. data/lib/neo4j/driver/exceptions/value/value_exception.rb +12 -0
  60. data/lib/neo4j/driver/internal/bolt_server_address.rb +97 -0
  61. data/lib/neo4j/driver/internal/duration_normalizer.rb +47 -0
  62. data/lib/neo4j/driver/internal/validator.rb +29 -0
  63. data/lib/neo4j/driver/summary/query_type.rb +12 -0
  64. data/lib/neo4j/driver/synchronizable.rb +23 -0
  65. data/lib/neo4j/driver/types/local_date_time.rb +20 -0
  66. data/lib/neo4j/driver/types/local_time.rb +19 -0
  67. data/lib/neo4j/driver/types/offset_time.rb +19 -0
  68. data/lib/neo4j/driver/types/point.rb +39 -0
  69. data/lib/neo4j/driver/types/time.rb +43 -0
  70. data/lib/neo4j/driver/version.rb +7 -0
  71. data/lib/neo4j_ruby_driver.rb +15 -0
  72. metadata +336 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bab0100e6ebde4c4522a587dc4f5d3448cd2ba9d014814c427d907432ebc3627
4
+ data.tar.gz: 4907a712afbce45c27b89672258c288303b757e88913c0037bf9edb078bc5e17
5
+ SHA512:
6
+ metadata.gz: 00eb88088196a005182e951e23b034ae14268023db985432770b9ead9b558925bd214491d3e2c7841697b3fcc4163e5bd35d3c3ff708a834322e2039e7fe4566
7
+ data.tar.gz: 6b25acdd0734c8876e7380293763093382ae2d1561f601ef48373b0e79c742e2d9a201bb55156eae3e8af0df543087ecd3c79ab9534731a83a9c7d80c24f7530
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Heinrich Klobuczek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # Neo4j::Driver
2
+
3
+ home :: https://github.com/neo4jrb/neo4j-ruby-driver
4
+
5
+ This repository contains 2 implementation of a neo4j driver for ruby:
6
+ - based on official java implementation. It provides a thin wrapper over the java driver (only on jruby).
7
+ - pure ruby implmementation. Available on all ruby versions >= 3.1.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'neo4j-ruby-driver'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install neo4j-ruby-driver
24
+
25
+ ## Server Compatibility
26
+
27
+ The compatibility with Neo4j Server versions is documented in the [Neo4j Knowledge Base](https://neo4j.com/developer/kb/neo4j-supported-versions/).
28
+
29
+ ## Usage
30
+
31
+ The API is to highest possible degree consistent with the official java driver.
32
+ At this moment [The Neo4j Drivers Manual v4.4](https://neo4j.com/docs/java-manual/current/) along with the ruby version of the [code fragments](https://github.com/neo4jrb/neo4j-ruby-driver/blob/master/docs/dev_manual_examples.rb) and the ruby specs provide the only documentation.
33
+
34
+ [Neo4j Java Driver 4.3 API](https://neo4j.com/docs/api/java-driver/current/) can be helpful as well..
35
+
36
+ ## Development
37
+
38
+ This gem includes 2 different implementations: java driver wrapper and pure ruby driver
39
+
40
+ $ bin/setup
41
+
42
+ ## Testing
43
+
44
+ To run the tests the following tools need to be installed:
45
+
46
+ $ brew install python
47
+ $ pip3 install --user git+https://github.com/klobuczek/boltkit@1.3#egg=boltkit
48
+ $ neoctrl-install -e 4.4.5 servers
49
+ $ neoctrl-configure servers/neo4j-enterprise-4.4.5 dbms.directories.import= dbms.default_listen_address=::
50
+ $ neoctrl-set-initial-password pass servers/neo4j-enterprise-4.4.5
51
+ $ neoctrl-start servers/neo4j-enterprise-4.4.5
52
+
53
+ To run the tests:
54
+ ```console
55
+ $ bin/setup
56
+ $ rspec spec
57
+ ```
58
+
59
+ In case of heap space memory error (`org.neo4j.driver.exceptions.DatabaseException: Java heap space`), you should limit the dbms memory, for example:
60
+
61
+ ```console
62
+ $ neoctrl-configure servers/neo4j-enterprise-4.4.5 dbms.memory.pagecache.size=600m dbms.memory.heap.max_size=600m dbms.memory.heap.initial_size=600m dbms.directories.import= dbms.connectors.default_listen_address=::
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ Suggestions, improvements, bug reports and pull requests are welcome on GitHub at https://github.com/neo4jrb/neo4j-ruby-driver.
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
72
+
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j::Driver::Ext
4
+ module AsyncConverter
5
+ include ExceptionMapper
6
+
7
+ private
8
+
9
+ class Variable
10
+ def initialize(condition = ::Async::Condition.new)
11
+ @condition = condition
12
+ @value = nil
13
+ end
14
+
15
+ def resolve(value = true)
16
+ @value = value
17
+ condition = @condition
18
+ @condition = nil
19
+
20
+ self.freeze
21
+
22
+ condition.signal(value)
23
+ end
24
+
25
+ def resolved?
26
+ @condition.nil?
27
+ end
28
+
29
+ def value
30
+ @condition&.wait
31
+ return @value
32
+ end
33
+
34
+ def wait
35
+ self.value
36
+ end
37
+ end
38
+
39
+ def to_future(completion_stage)
40
+ Concurrent::Promises.resolvable_future.tap do |future|
41
+ completion_stage.then_apply(&future.method(:fulfill)).exceptionally { |e| future.reject(mapped_exception(e.cause)) }
42
+ end
43
+ end
44
+
45
+ def to_async(completion_stage)
46
+ variable = Variable.new
47
+ completion_stage.when_complete do |value, error|
48
+ variable.resolve([value, error])
49
+ end
50
+ value, error = variable.wait
51
+ raise mapped_exception(e.cause) if error
52
+ value
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module AuthTokens
7
+ include NeoConverter
8
+
9
+ def basic(username, password, realm = nil)
10
+ Neo4j::Driver::Internal::Validator.require_non_nil_credentials!(username, password)
11
+ super
12
+ end
13
+
14
+ def custom(principal, credentials, realm, scheme, **parameters)
15
+ super(principal, credentials, realm, scheme, to_neo(parameters))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module Bookmark
7
+ module ClassMethods
8
+ def from(*values)
9
+ super(java.util.HashSet.new(values))
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module ConfigConverter
7
+ include NeoConverter
8
+
9
+ private
10
+
11
+ def to_java_config(builder_class, **hash)
12
+ apply_to(builder_class.builder, **hash).build
13
+ end
14
+
15
+ def apply_to(builder, **hash)
16
+ hash.compact.reduce(builder) { |object, key_value| object.send(*config_method(*key_value)) }
17
+ end
18
+
19
+ def config_method(key, value)
20
+ method = :"with_#{key}"
21
+ unit = nil
22
+ case key.to_s
23
+ when 'encryption', 'driver_metrics', 'hostname_verification'
24
+ method = :"without_#{key}" unless value
25
+ value = nil
26
+ when 'timeout'
27
+ value = java.time.Duration.ofMillis(Driver::Internal::DurationNormalizer.milliseconds(value))
28
+ when /time(out)?$/
29
+ value = Driver::Internal::DurationNormalizer.milliseconds(value) || -1
30
+ unit = java.util.concurrent.TimeUnit::MILLISECONDS
31
+ when 'logger'
32
+ method = :with_logging
33
+ value = Neo4j::Driver::Ext::Logger.new(value)
34
+ when 'resolver'
35
+ proc = value
36
+ value = ->(address) { java.util.HashSet.new(proc.call(address)) }
37
+ when 'bookmarks'
38
+ return [method, *value]
39
+ when 'trust_strategy'
40
+ value = trust_strategy(**value)
41
+ when 'revocation_strategy'
42
+ method = case value
43
+ when Neo4j::Driver::Internal::RevocationStrategy::NO_CHECKS
44
+ 'without_certificate_revocation_checks'
45
+ else
46
+ "with_#{value}_revocation_checks"
47
+ end
48
+ else
49
+ value = to_neo(value, skip_unknown: true)
50
+ end
51
+ [method, value, unit].compact
52
+ end
53
+
54
+ def trust_strategy(**config)
55
+ strategy = config.delete(:strategy)
56
+ trust_strategy =
57
+ case strategy
58
+ when :trust_custom_certificates
59
+ Config::TrustStrategy
60
+ .trust_custom_certificate_signed_by(*config.delete(:cert_files).map(&java.io.File.method(:new)))
61
+ else
62
+ Config::TrustStrategy.send(strategy)
63
+ end
64
+ apply_to(trust_strategy, **config)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module ExceptionCheckable
7
+ include ExceptionMapper
8
+
9
+ def check
10
+ yield
11
+ rescue Java::JavaLang::RuntimeException => e
12
+ raise mapped_exception(e)
13
+ end
14
+
15
+ def reverse_check
16
+ yield
17
+ rescue Neo4j::Driver::Exceptions::ServiceUnavailableException => e
18
+ raise(throwable(e.cause) || Java::OrgNeo4jDriverExceptions::ServiceUnavailableException.new(e.message))
19
+ rescue Neo4j::Driver::Exceptions::Neo4jException,
20
+ Neo4j::Driver::Exceptions::NoSuchRecordException,
21
+ Neo4j::Driver::Exceptions::UntrustedServerException,
22
+ Neo4j::Driver::Exceptions::IllegalStateException => e
23
+ raise(throwable(e.cause) || e)
24
+ end
25
+
26
+ private
27
+
28
+ def throwable(e)
29
+ e if e.is_a? Java::JavaLang::Throwable
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module ExceptionMapper
7
+ java_import org.neo4j.driver.exceptions.AuthenticationException
8
+ java_import org.neo4j.driver.exceptions.AuthorizationExpiredException
9
+ java_import org.neo4j.driver.exceptions.ClientException
10
+ java_import org.neo4j.driver.exceptions.ConnectionReadTimeoutException
11
+ java_import org.neo4j.driver.exceptions.DatabaseException
12
+ java_import org.neo4j.driver.exceptions.DiscoveryException
13
+ java_import org.neo4j.driver.exceptions.FatalDiscoveryException
14
+ java_import org.neo4j.driver.exceptions.ProtocolException
15
+ java_import org.neo4j.driver.exceptions.ResultConsumedException
16
+ java_import org.neo4j.driver.exceptions.SecurityException
17
+ java_import org.neo4j.driver.exceptions.ServiceUnavailableException
18
+ java_import org.neo4j.driver.exceptions.SessionExpiredException
19
+ java_import org.neo4j.driver.exceptions.TokenExpiredException
20
+ java_import org.neo4j.driver.exceptions.TransactionNestingException
21
+ java_import org.neo4j.driver.exceptions.TransientException
22
+ java_import org.neo4j.driver.exceptions.UntrustedServerException
23
+
24
+ def mapped_exception(exception)
25
+ mapped_neo4j_exception_class(exception)&.new(*arguments(exception)) ||
26
+ mapped_runtime_exception_class(exception)&.new(exception.message) || exception
27
+ end
28
+
29
+ def arguments(e)
30
+ [e.code, e.message, e.suppressed.map(&method(:mapped_exception))]
31
+ end
32
+
33
+ private
34
+
35
+ def mapped_neo4j_exception_class(exception_class)
36
+ case exception_class
37
+ when AuthenticationException
38
+ Neo4j::Driver::Exceptions::AuthenticationException
39
+ when AuthorizationExpiredException
40
+ Neo4j::Driver::Exceptions::AuthorizationExpiredException
41
+ when FatalDiscoveryException
42
+ Neo4j::Driver::Exceptions::FatalDiscoveryException
43
+ when ResultConsumedException
44
+ Neo4j::Driver::Exceptions::ResultConsumedException
45
+ when TokenExpiredException
46
+ Neo4j::Driver::Exceptions::TokenExpiredException
47
+ when SecurityException
48
+ Neo4j::Driver::Exceptions::SecurityException
49
+ when TransactionNestingException
50
+ Neo4j::Driver::Exceptions::TransactionNestingException
51
+ when ClientException
52
+ Neo4j::Driver::Exceptions::ClientException
53
+ when ConnectionReadTimeoutException
54
+ Neo4j::Driver::Exceptions::ConnectionReadTimeoutException
55
+ when DatabaseException
56
+ Neo4j::Driver::Exceptions::DatabaseException
57
+ when DiscoveryException
58
+ Neo4j::Driver::Exceptions::DiscoveryException
59
+ when ProtocolException
60
+ Neo4j::Driver::Exceptions::ProtocolException
61
+ when ServiceUnavailableException
62
+ Neo4j::Driver::Exceptions::ServiceUnavailableException
63
+ when SessionExpiredException
64
+ Neo4j::Driver::Exceptions::SessionExpiredException
65
+ when TransientException
66
+ Neo4j::Driver::Exceptions::TransientException
67
+ else
68
+ nil
69
+ end
70
+ end
71
+
72
+ def mapped_runtime_exception_class(exception_class)
73
+ case exception_class
74
+ when Java::OrgNeo4jDriverExceptions::NoSuchRecordException
75
+ Neo4j::Driver::Exceptions::NoSuchRecordException
76
+ when Java::OrgNeo4jDriverExceptions::UntrustedServerException
77
+ Neo4j::Driver::Exceptions::UntrustedServerException
78
+ when Java::JavaLang::IllegalStateException
79
+ Neo4j::Driver::Exceptions::IllegalStateException
80
+ when Java::JavaLang::IllegalArgumentException
81
+ ArgumentError
82
+ else
83
+ nil
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module GraphDatabase
7
+ extend AutoClosable
8
+ include ConfigConverter
9
+ include ExceptionCheckable
10
+
11
+ auto_closable :driver, :routing_driver
12
+
13
+ def driver(uri, auth_token = Neo4j::Driver::AuthTokens.none, **config)
14
+ check do
15
+ java_method(:driver, [java.lang.String, org.neo4j.driver.AuthToken, org.neo4j.driver.Config])
16
+ .call(uri.to_s, auth_token, to_java_config(Neo4j::Driver::Config, **config))
17
+ end
18
+ end
19
+
20
+ def routing_driver(routing_uris, auth_token, **config)
21
+ check do
22
+ super(routing_uris.map { |uri| java.net.URI.create(uri.to_s) }, auth_token,
23
+ to_java_config(Neo4j::Driver::Config, **config))
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module Internal
7
+ module Async
8
+ module InternalAsyncSession
9
+ include ConfigConverter
10
+ include RunOverride
11
+ include AsyncConverter
12
+
13
+ def run_async(statement, parameters = {}, config = {})
14
+ to_future(
15
+ java_method(:runAsync, [org.neo4j.driver.Query, org.neo4j.driver.TransactionConfig])
16
+ .call(to_statement(statement, parameters), to_java_config(Neo4j::Driver::TransactionConfig, config)))
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j::Driver::Ext
4
+ module Internal
5
+ module Cluster
6
+ module RoutingTableRegistryImpl
7
+ def routing_table_handler(database)
8
+ get_routing_table_handler(org.neo4j.driver.internal.DatabaseNameUtil.database(database)).then do |it|
9
+ it.get if it.present?
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j::Driver::Ext
4
+ module Internal
5
+ module Cursor
6
+ module DisposableAsyncResultCursor
7
+ include AsyncConverter
8
+
9
+ def next_async
10
+ to_future(super)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module Internal
7
+ module Metrics
8
+ module InternalConnectionPoolMetrics
9
+ def address
10
+ java_class.declared_method('getAddress').tap { |m| m.accessible = true }.invoke(java_object)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module Internal
7
+ module Summary
8
+ module InternalResultSummary
9
+ java_import org.neo4j.driver.summary.QueryType
10
+
11
+ %i[result_available_after result_consumed_after].each do |method|
12
+ define_method(method) { super(Java::JavaUtilConcurrent::TimeUnit::MILLISECONDS) }
13
+ end
14
+
15
+ def query_type
16
+ case super
17
+ when QueryType::READ_ONLY
18
+ Driver::Summary::QueryType::READ_ONLY
19
+ when QueryType::READ_WRITE
20
+ Driver::Summary::QueryType::READ_WRITE
21
+ when QueryType::WRITE_ONLY
22
+ Driver::Summary::QueryType::WRITE_ONLY
23
+ when QueryType::SCHEMA_WRITE
24
+ Driver::Summary::QueryType::SCHEMA_WRITE
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalDriver
7
+ extend AutoClosable
8
+ include ConfigConverter
9
+ include ExceptionCheckable
10
+ include AsyncConverter
11
+
12
+ auto_closable :session
13
+
14
+ def session(**session_config)
15
+ java_method(:session, [org.neo4j.driver.SessionConfig])
16
+ .call(to_java_config(Neo4j::Driver::SessionConfig, session_config))
17
+ end
18
+
19
+ def async_session(**session_config)
20
+ java_method(:asyncSession, [org.neo4j.driver.SessionConfig])
21
+ .call(to_java_config(Neo4j::Driver::SessionConfig, session_config))
22
+ end
23
+
24
+ def close_async
25
+ to_future(super)
26
+ end
27
+
28
+ def verify_connectivity
29
+ check { super }
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalEntity
7
+ include MapConverter
8
+
9
+ alias properties to_h
10
+
11
+ def [](key)
12
+ get(key.to_s).as_ruby_object
13
+ end
14
+
15
+ def ==(other)
16
+ java_method(:isEqual).call(other)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalKeys
7
+ include ExceptionCheckable
8
+
9
+ def keys
10
+ check { super.map(&:to_sym) }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalNode
7
+ def labels
8
+ super.map(&:to_sym)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalRecord
7
+ include MapConverter
8
+ include InternalKeys
9
+
10
+ def values
11
+ java_send(:values).map(&:as_ruby_object)
12
+ end
13
+
14
+ def [](key)
15
+ case key
16
+ when Integer
17
+ java_method(:get, [Java::int]).call(key)
18
+ else
19
+ java_method(:get, [java.lang.String]).call(key.to_s)
20
+ end.as_ruby_object
21
+ end
22
+
23
+ def first
24
+ java_method(:get, [Java::int]).call(0).as_ruby_object
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalRelationship
7
+ def type
8
+ super.to_sym
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalResult
7
+ include Enumerable
8
+ include ExceptionCheckable
9
+ include InternalKeys
10
+
11
+ %i[has_next? next single consume peek].each do |method|
12
+ define_method(method) do |*args, &block|
13
+ check { super(*args, &block) }
14
+ end
15
+ end
16
+
17
+ def each(&block)
18
+ check { stream.for_each(&block) }
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end