Module: Neo4j::Driver::Internal::DurationNormalizer
- Included in:
- Session
- Defined in:
- lib/neo4j/driver/internal/duration_normalizer.rb
Instance Method Summary collapse
-
#timeout_to_milliseconds(timeout) ⇒ Object
Convert timeout from seconds (or ActiveSupport::Duration) to milliseconds for the Bolt protocol.
Instance Method Details
#timeout_to_milliseconds(timeout) ⇒ Object
Convert timeout from seconds (or ActiveSupport::Duration) to milliseconds for the Bolt protocol. A negative timeout is invalid — reject it client-side (matches Java, which raises rather than sending a negative tx_timeout to the server).
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/neo4j/driver/internal/duration_normalizer.rb', line 11 def timeout_to_milliseconds(timeout) return if timeout.nil? # Check the sign before rounding: a tiny negative timeout # (e.g. -0.4ms) would otherwise round to 0 and slip through. ms = timeout.to_f * 1000 raise Exceptions::ClientException, "Transaction timeout must not be negative, but was #{ms}ms" if ms.negative? ms.round end |