Skip to content

Commit

Permalink
Merge branch '7.2.x' into 8.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerfulstoic committed Oct 23, 2017
2 parents 1fb2470 + 50754f5 commit 28f5d66
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,12 +3,24 @@ All notable changes to this project will be documented in this file.
This file should follow the standards specified on [http://keepachangelog.com/]
This project adheres to [Semantic Versioning](http://semver.org/).

## [8.0.1] - 2017-10-22

### Added

- Allow configuration of timeout in Bolt adaptor (thanks @amiel / see #304)

## [8.0.0] - 2017-10-15

### Changed

- `neo4j-rake_tasks` gem is no longer a dependency for `neo4j-core`. Because many people don't use it, and because many people don't understand it, it will now need to be explicitly required for your project

## [7.2.4] - 2017-10-22

### Added

- Allow configuration of timeout in Bolt adaptor

## [7.2.3] - 2017-08-22

### Fixed
Expand Down
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -7,12 +7,16 @@ It can be used standalone without the neo4j gem.

### Executing Cypher queries

To make a basic connection to Neo4j to execute Cypher queries, first choose an adaptor. Adaptors for HTTP and Embedded mode (jRuby only) are available (support for Neo4j 3.0's [Bolt protocol](http://alpha.neohq.net/docs/server-manual/bolt.html) is planned). You can create an adaptor like:
To make a basic connection to Neo4j to execute Cypher queries, first choose an adaptor. Adaptors for HTTP, Bolt, and Embedded mode (jRuby only) are available. You can create an adaptor like:

http_adaptor = Neo4j::Core::CypherSession::Adaptors::HTTP.new('http://neo4j:pass@localhost:7474')

# or

bolt_adaptor = Neo4j::Core::CypherSession::Adaptors::Bolt.new('http://neo4j:pass@localhost:7474', timeout: 10)

# or

neo4j_adaptor = Neo4j::Core::CypherSession::Adaptors::Embedded.new('/file/path/to/graph.db')

Once you have an adaptor you can create a session like so:
Expand Down Expand Up @@ -56,7 +60,6 @@ When doing batched queries, there is also a shortcut for getting a new `Neo4j::C
### 3.0+ Documentation:

* http://neo4jrb.readthedocs.org/en/stable/
* https://github.com/neo4jrb/neo4j-core/wiki

### 2.x Documentation

Expand Down
2 changes: 1 addition & 1 deletion lib/neo4j-core/version.rb
@@ -1,5 +1,5 @@
module Neo4j
module Core
VERSION = '8.0.0'
VERSION = '8.0.1'
end
end
6 changes: 5 additions & 1 deletion lib/neo4j/core/cypher_session/adaptors/bolt.rb
Expand Up @@ -185,7 +185,7 @@ def sendmsg(message)
@socket.send(message, 0)
end

def recvmsg(size, timeout = 10)
def recvmsg(size, timeout = timeout_option)
Timeout.timeout(timeout) do
@socket.recv(size).tap do |result|
log_message :S, result
Expand Down Expand Up @@ -228,6 +228,10 @@ def flush_response
[].tap { |r| while arg = unpacker.unpack_value!; r << arg; end }
end

def timeout_option
@options.fetch(:timeout) { 10 }
end

# Represents messages sent to or received from the server
class Message
TYPE_CODES = {
Expand Down
16 changes: 16 additions & 0 deletions spec/neo4j/core/cypher_session/adaptors/bolt_spec.rb
Expand Up @@ -58,4 +58,20 @@

it_behaves_like 'Neo4j::Core::CypherSession::Adaptor'
end

describe 'timeouts' do
it 'defaults to 10' do
expect(Timeout).to receive(:timeout).with(10)
adaptor.send(:recvmsg, 1)
end

context 'when a timeout is configured' do
let(:adaptor) { adaptor_class.new(url, timeout: 20) }

it 'uses the configured timeout' do
expect(Timeout).to receive(:timeout).with(20)
adaptor.send(:recvmsg, 1)
end
end
end
end

0 comments on commit 28f5d66

Please sign in to comment.