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
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalSession
7
+ extend AutoClosable
8
+ include ConfigConverter
9
+ include ExceptionCheckable
10
+ include RunOverride
11
+
12
+ auto_closable :begin_transaction
13
+
14
+ # work around jruby issue https://github.com/jruby/jruby/issues/5603
15
+ Struct.new('Wrapper', :object)
16
+
17
+ %i[read write].each do |prefix|
18
+ define_method("#{prefix}_transaction") do |**config, &block|
19
+ check do
20
+ super(->(tx) { Struct::Wrapper.new(reverse_check { block.call(tx) }) }, to_java_config(Neo4j::Driver::TransactionConfig, config)).object
21
+ end
22
+ end
23
+ end
24
+
25
+ # end work around
26
+
27
+ def run(statement, parameters = {}, config = {})
28
+ check do
29
+ java_method(:run, [org.neo4j.driver.Query, org.neo4j.driver.TransactionConfig])
30
+ .call(to_statement(statement, parameters), to_java_config(Neo4j::Driver::TransactionConfig, config))
31
+ end
32
+ end
33
+
34
+ def begin_transaction(**config)
35
+ check { super(to_java_config(Neo4j::Driver::TransactionConfig, config)) }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module InternalTransaction
7
+ include ExceptionCheckable
8
+ include RunOverride
9
+
10
+ def run(statement, **parameters)
11
+ check { super(to_statement(statement, parameters)) }
12
+ end
13
+
14
+ def commit
15
+ check { super }
16
+ end
17
+
18
+ def rollback
19
+ check { super }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ class Logger
7
+ include org.neo4j.driver.Logger
8
+ include org.neo4j.driver.Logging
9
+
10
+ delegate :debug?, to: :@active_support_logger
11
+
12
+ def initialize(active_support_logger)
13
+ @active_support_logger = active_support_logger
14
+ end
15
+
16
+ def getLog(_name)
17
+ self
18
+ end
19
+ alias get_log getLog
20
+
21
+ def error(*args)
22
+ add(::Logger::ERROR, format(*args))
23
+ end
24
+
25
+ def info(*args)
26
+ add(::Logger::INFO, format(*args))
27
+ end
28
+
29
+ def warn(*args)
30
+ add(::Logger::WARN, format(*args))
31
+ end
32
+
33
+ def debug(*args)
34
+ add(::Logger::DEBUG, format(*args))
35
+ end
36
+
37
+ alias trace debug
38
+
39
+ def trace_enabled?
40
+ debug?
41
+ end
42
+
43
+ def debug_enabled
44
+ debug?
45
+ end
46
+
47
+ private
48
+
49
+ def add(level, *args)
50
+ @active_support_logger.add(level) { format(*args) }
51
+ end
52
+
53
+ def format(*args)
54
+ args.unshift('%s%n%s') if args.last.is_a? java.lang.Throwable
55
+ java.lang.String.format(*args)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module MapConverter
7
+ def to_h
8
+ java_method(:asMap, [java.util.function.Function]).call(&:itself).to_hash
9
+ .transform_values!(&:as_ruby_object).symbolize_keys!
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module NeoConverter
7
+ private
8
+
9
+ def to_neo(object, skip_unknown: false)
10
+ case object
11
+ when Hash
12
+ object.map { |key, value| [key.to_s, to_neo(value)] }.to_h
13
+ when Types::Path
14
+ Exceptions::ClientException.unable_to_convert(object)
15
+ when Enumerable
16
+ object.map(&method(:to_neo))
17
+ when String
18
+ object.encoding == Encoding::BINARY ? object.to_java_bytes : object
19
+ when ActiveSupport::Duration
20
+ Java::OrgNeo4jDriverInternal::InternalIsoDuration.new(
21
+ *Driver::Internal::DurationNormalizer.normalize(object)
22
+ )
23
+ when Types::Point
24
+ Java::OrgNeo4jDriver::Values.point(object.srid, *object.coordinates)
25
+ when Types::OffsetTime
26
+ Java::JavaTime::OffsetTime.of(object.hour, object.min, object.sec,
27
+ object.nsec, Java::JavaTime::ZoneOffset.of_total_seconds(object.utc_offset))
28
+ when Types::LocalTime
29
+ Java::JavaTime::LocalTime.of(object.hour, object.min, object.sec, object.nsec)
30
+ when Types::LocalDateTime
31
+ Java::JavaTime::LocalDateTime.of(object.year, object.month, object.day, object.hour, object.min, object.sec,
32
+ object.nsec)
33
+ when ActiveSupport::TimeWithZone
34
+ to_zoned_date_time(object, object.time_zone.tzinfo.identifier)
35
+ when Time, DateTime
36
+ to_zoned_date_time(object, object.formatted_offset)
37
+ when Date
38
+ Java::JavaTime::LocalDate.of(object.year, object.month, object.day)
39
+ when Symbol
40
+ object.to_s
41
+ when nil, true, false, Integer, Float
42
+ object
43
+ else
44
+ if skip_unknown
45
+ object
46
+ else
47
+ raise Exceptions::ClientException.unable_to_convert(object)
48
+ end
49
+ end
50
+ end
51
+
52
+ def to_zoned_date_time(object, zone)
53
+ Java::JavaTime::ZonedDateTime.of(object.year, object.month, object.day, object.hour, object.min, object.sec,
54
+ object.nsec, Java::JavaTime::ZoneId.of(zone))
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module Query
7
+ def parameters
8
+ super.as_ruby_object
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module RubyConverter
7
+ include MapConverter
8
+
9
+ def as_ruby_object
10
+ case type_constructor
11
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::LIST
12
+ values(&:itself).map(&:as_ruby_object)
13
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::MAP
14
+ to_h
15
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::DATE
16
+ date = as_local_date
17
+ Date.new(date.year, date.month_value, date.day_of_month)
18
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::DURATION
19
+ ActiveSupport::Duration.parse(as_iso_duration.to_s)
20
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::POINT
21
+ point = as_point
22
+ Types::Point.new(srid: point.srid, x: point.x, y: point.y, z: nullable(point.z))
23
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::BYTES
24
+ String.from_java_bytes(as_byte_array).force_encoding(Encoding::BINARY)
25
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::TIME
26
+ Types::OffsetTime.parse(as_offset_time.to_string)
27
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::LOCAL_TIME
28
+ Types::LocalTime.parse(as_local_time.to_string)
29
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::LOCAL_DATE_TIME
30
+ Types::LocalDateTime.parse(as_local_date_time.to_string)
31
+ when Java::OrgNeo4jDriverInternalTypes::TypeConstructor::DATE_TIME
32
+ to_time
33
+ else
34
+ as_object
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def to_time
41
+ time = as_zoned_date_time
42
+ zone_id = time.zone.id
43
+ if /^Z|[+\-][0-9]{2}:[0-9]{2}$/.match?(zone_id)
44
+ Time.parse(time.to_string)
45
+ else
46
+ instant = time.to_instant
47
+ Time.at(instant.epoch_second, instant.nano, :nsec).in_time_zone(TZInfo::Timezone.get(zone_id))
48
+ end
49
+ end
50
+
51
+ def nullable(double)
52
+ double unless double == java.lang.Double::NaN
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module RunOverride
7
+ include NeoConverter
8
+
9
+ def close
10
+ check { super }
11
+ end
12
+
13
+ private
14
+
15
+ def to_statement(text, parameters)
16
+ Neo4j::Driver::Internal::Validator.require_hash_parameters!(parameters)
17
+ Neo4j::Driver::Query.new(text, to_neo(parameters || {}))
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Ext
6
+ module StartEndNaming
7
+ def start_node
8
+ java_send(:start)
9
+ end
10
+
11
+ def end_node
12
+ java_send(:end)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/hash/keys'
4
+ require 'date'
5
+ require 'loader'
6
+ require 'neo4j-ruby-driver_jars'
7
+
8
+ Loader.load
9
+
10
+ module Neo4j
11
+ module Driver
12
+ include_package 'org.neo4j.driver'
13
+
14
+ Record = Java::OrgNeo4jDriverInternal::InternalRecord
15
+ Result = Java::OrgNeo4jDriverInternal::InternalResult
16
+ Transaction = Java::OrgNeo4jDriverInternal::InternalTransaction
17
+
18
+ module Net
19
+ include_package 'org.neo4j.driver.net'
20
+ end
21
+
22
+ module Summary
23
+ include_package 'org.neo4j.driver.summary'
24
+ end
25
+
26
+ module Types
27
+ Entity = Java::OrgNeo4jDriverInternal::InternalEntity
28
+ Node = Java::OrgNeo4jDriverInternal::InternalNode
29
+ Path = Java::OrgNeo4jDriverInternal::InternalPath
30
+ Relationship = Java::OrgNeo4jDriverInternal::InternalRelationship
31
+ end
32
+ end
33
+ end
34
+
35
+ Java::OrgNeo4jDriver::AuthTokens.singleton_class.prepend Neo4j::Driver::Ext::AuthTokens
36
+ Java::OrgNeo4jDriver::Bookmark.singleton_class.prepend Neo4j::Driver::Ext::Bookmark::ClassMethods
37
+ Java::OrgNeo4jDriver::GraphDatabase.singleton_class.prepend Neo4j::Driver::Ext::GraphDatabase
38
+ Java::OrgNeo4jDriver::Query.prepend Neo4j::Driver::Ext::Query
39
+ Java::OrgNeo4jDriverInternal::InternalDriver.prepend Neo4j::Driver::Ext::InternalDriver
40
+ Java::OrgNeo4jDriverInternal::InternalEntity.include Neo4j::Driver::Ext::InternalEntity
41
+ Java::OrgNeo4jDriverInternal::InternalNode.prepend Neo4j::Driver::Ext::InternalNode
42
+ Java::OrgNeo4jDriverInternal::InternalPath.include Neo4j::Driver::Ext::StartEndNaming
43
+ Java::OrgNeo4jDriverInternal::InternalPath::SelfContainedSegment.include Neo4j::Driver::Ext::StartEndNaming
44
+ Java::OrgNeo4jDriverInternal::InternalRecord.prepend Neo4j::Driver::Ext::InternalRecord
45
+ Java::OrgNeo4jDriverInternal::InternalRelationship.prepend Neo4j::Driver::Ext::InternalRelationship
46
+ Java::OrgNeo4jDriverInternal::InternalResult.prepend Neo4j::Driver::Ext::InternalResult
47
+ Java::OrgNeo4jDriverInternal::InternalSession.prepend Neo4j::Driver::Ext::InternalSession
48
+ Java::OrgNeo4jDriverInternal::InternalTransaction.prepend Neo4j::Driver::Ext::InternalTransaction
49
+ Java::OrgNeo4jDriverInternalAsync::InternalAsyncSession.prepend Neo4j::Driver::Ext::Internal::Async::InternalAsyncSession
50
+ Java::OrgNeo4jDriverInternalCluster::RoutingTableRegistryImpl.include Neo4j::Driver::Ext::Internal::Cluster::RoutingTableRegistryImpl
51
+ Java::OrgNeo4jDriverInternalCursor::DisposableAsyncResultCursor.prepend Neo4j::Driver::Ext::Internal::Cursor::DisposableAsyncResultCursor
52
+ Java::OrgNeo4jDriverInternalMetrics::InternalConnectionPoolMetrics.include Neo4j::Driver::Ext::Internal::Metrics::InternalConnectionPoolMetrics
53
+ Java::OrgNeo4jDriverInternalSummary::InternalResultSummary.prepend Neo4j::Driver::Ext::Internal::Summary::InternalResultSummary
54
+ Java::OrgNeo4jDriverInternalValue::ValueAdapter.include Neo4j::Driver::Ext::RubyConverter
data/lib/loader.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'zeitwerk'
4
+
5
+ class Loader
6
+ def self.load
7
+ loader = Zeitwerk::Loader.new
8
+ loader.tag = 'neo4j-ruby-driver'
9
+ loader.push_dir(File.expand_path(__dir__))
10
+ loader.push_dir(File.dirname(File.dirname(caller_locations(1..1).first.path)))
11
+ yield loader if block_given?
12
+ loader.ignore(File.expand_path('neo4j-*-driver_jars.rb', __dir__))
13
+ loader.ignore(File.expand_path('neo4j_ruby_driver.rb', __dir__))
14
+ loader.ignore(File.expand_path('org', __dir__))
15
+ loader.inflector = Zeitwerk::GemInflector.new(File.expand_path('neo4j/driver', __dir__))
16
+ loader.setup
17
+ loader.eager_load
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module AutoClosable
6
+ def auto_closable(*methods)
7
+ prepend with_block_definer(methods)
8
+ end
9
+
10
+ private
11
+
12
+ def with_block_definer(methods)
13
+ Module.new do
14
+ methods.each do |method|
15
+ define_method(method) do |*args, **kwargs, &block|
16
+ closable = super(*args, **kwargs)
17
+ if block
18
+ begin
19
+ block.arity.zero? ? closable.instance_eval(&block) : block.call(closable)
20
+ ensure
21
+ closable&.close
22
+ end
23
+ else
24
+ closable
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # Failed to authenticate the driver to the server due to bad credentials provided.
7
+ # When this error happens, the error could be recovered by closing the current driver and restart a new driver with
8
+ # the correct credentials.
9
+
10
+ # @since 1.1
11
+ class AuthenticationException < SecurityException
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # The authorization info maintained on the server has expired. The client should reconnect.
7
+ # <p>
8
+ # Error code: Neo.ClientError.Security.AuthorizationExpired
9
+ class AuthorizationExpiredException < SecurityException
10
+ DESCRIPTION = 'Authorization information kept on the server has expired, this connection is no longer valid.'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ class CertificateException
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # A <em>ClientException</em> indicates that the client has carried out an operation incorrectly.
7
+ # The error code provided can be used to determine further detail for the problem.
8
+ # @since 1.0
9
+ class ClientException < Neo4jException
10
+ class << self
11
+ def unable_to_convert(object)
12
+ raise self, "Unable to convert #{object.class.name} to Neo4j Value."
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # Indicates that read timed out due to it taking longer than the server-supplied timeout value via the {@code connection.recv_timeout_seconds} configuration
7
+ # hint. The server might provide this value to clients to let them know when a given connection may be considered broken if client does not get any
8
+ # communication from the server within the specified timeout period. This results in the server being removed from the routing table.
9
+ class ConnectionReadTimeoutException < ServiceUnavailableException
10
+ INSTANCE = new('Connection read timed out due to it taking longer than the server-supplied timeout value via configuration hint.')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # A <em>DatabaseException</em> indicates that there is a problem within the underlying database.
7
+ # The error code provided can be used to determine further detail for the problem.
8
+ # @since 1.0
9
+ class DatabaseException < Neo4jException
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # An error has happened while getting routing table with a remote server.
7
+ # While this error is not fatal and we might be able to recover if we continue trying on another server.
8
+ # If we fail to get a valid routing table from all routing servers known to this driver,
9
+ # then we will end up with a fatal error {@link ServiceUnavailableException}.
10
+
11
+ # If you see this error in your logs, it is safe to ignore if your cluster is temporarily changing structure during that time.
12
+ class DiscoveryException < Neo4jException
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # This error indicate a fatal problem to obtain routing tables such as the routing table for a specified database does not exist.
7
+ # This exception should not be retried.
8
+ # @since 4.0
9
+ class FatalDiscoveryException < ClientException
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ class IllegalStateException < RuntimeError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ class Neo4jException < RuntimeError
7
+ attr_reader :code, :suppressed
8
+
9
+ def initialize(*args)
10
+ @code = args.shift if args.count > 1
11
+ message = args.shift
12
+ @suppressed = args.shift
13
+ super(message)
14
+ end
15
+
16
+ def add_suppressed(exception)
17
+ (@suppressed ||= []) << exception
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ class NoSuchRecordException < RuntimeError
7
+ EMPTY = 'Cannot retrieve a single record, because this result is empty.'
8
+ TOO_MANY = 'Expected a result with a single record, but this result ' \
9
+ 'contains at least one more. Ensure your query returns only one record.'
10
+ NO_MORE = 'No more records'
11
+ NO_PEEK_PAST = 'Cannot peek past the last record'
12
+
13
+ class << self
14
+ def empty
15
+ new(EMPTY)
16
+ end
17
+
18
+ def too_many
19
+ new(TOO_MANY)
20
+ end
21
+
22
+ def no_more
23
+ new(NO_MORE)
24
+ end
25
+
26
+ def no_peek_past
27
+ new(NO_PEEK_PAST)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # A signal that the contract for client-server communication has broken down.
7
+ # The user should contact support and cannot resolve this his or herself.
8
+ class ProtocolException < Neo4jException
9
+ CODE = "Protocol violation: "
10
+
11
+ def initialize(message, e)
12
+ super("#{CODE}message", e)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # A user is trying to access resources that are no longer valid due to
7
+ # the resources have already been consumed or
8
+ # the {@link QueryRunner} where the resources are created has already been closed.
9
+ class ResultConsumedException < ClientException
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # Failed to communicate with the server due to security errors.
7
+ # When this type of error happens, the security cause of the error should be fixed to ensure the safety of your data.
8
+ # Restart of server/driver/cluster might be required to recover from this error.
9
+ # @since 1.1
10
+ class SecurityException < ClientException
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Exceptions
6
+ # An <em>ServiceUnavailableException</em> indicates that the driver cannot communicate with the cluster.
7
+ # @since 1.1
8
+ class ServiceUnavailableException < Neo4jException
9
+ end
10
+ end
11
+ end
12
+ end