Bolt.Sips v0.2.1 Bolt.Sips
A Neo4j Elixir driver wrapped around the Bolt protocol.
Summary
Functions
begin a new transaction
given you have an open transaction, you can use this to send a commit request
returns an environment specific Bolt.Sips configuration
returns a Bolt.Sips.Connection
sends the query (and its parameters) to the server and returns {:ok, Bolt.Sips.Response}
or
{:error, error}
otherwise
send a query and an associated map of parameters. Returns the server response or an error
The same as query/2 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise
The same as query/3 but raises a Bolt.Sips.Exception if it fails
given that you have an open transaction, you can send a rollback request. The server will rollback the transaction. Any further statements trying to run in this transaction will fail immediately
Start the connection process and connect to Neo4j
Functions
given you have an open transaction, you can use this to send a commit request
query(Bolt.Sips.Connection, String.t) :: {:ok, Bolt.Sips.Response} | {:error, Bolt.Sips.Error}
sends the query (and its parameters) to the server and returns {:ok, Bolt.Sips.Response}
or
{:error, error}
otherwise
send a query and an associated map of parameters. Returns the server response or an error
query!(Bolt.Sips.Connection, String.t) :: Bolt.Sips.Response | Bolt.Sips.Exception
The same as query/2 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise.
given that you have an open transaction, you can send a rollback request. The server will rollback the transaction. Any further statements trying to run in this transaction will fail immediately.
Start the connection process and connect to Neo4j
Options:
:url
- If present, it will be used for extracting the host name, the port and the authentication details and will override the: hostname, port, username and the password, if these were already defined! Since this driver is devoted to the Bolt protocol only, the protocol if present in the url will be ignored and considered by defaultbolt://
:hostname
- Server hostname (default: NEO4J_HOST env variable, then localhost);:port
- Server port (default: NEO4J_PORT env variable, then 7687);:username
- Username;:password
- User password;:pool_size
- maximum pool size;:max_overflow
- maximum number of workers created if pool is empty:timeout
- Connect timeout in milliseconds (default:15000
) Poolboy will block the current process and wait for an available worker, failing after a timeout, when the pool is full;:retry_linear_backoff
- with Bolt, the initial handshake sequence (happening before sending any commands to the server) is represented by two important calls, executed in sequence:handshake
andinit
, and they must both succeed, before sending any (Cypher) requests. You can see the details in the Bolt protocol specs. This sequence is also sensitive to latencies, such as: network latencies, busy servers, etc., and because of that we’re introducing a simple support for retrying the handshake (and the subsequent requests) with a linear backoff, and try the handshake sequence (or the request) a couple of times before giving up. See examples below.
Example of valid configurations (i.e. defined in config/dev.exs) and usage:
config :bolt_sips, Bolt,
url: 'bolt://demo:demo@hobby-wowsoeasy.dbs.graphenedb.com:24786',
ssl: true
config :bolt_sips, Bolt,
url: "bolt://Bilbo:Baggins@hobby-hobbits.dbs.graphenedb.com:24786",
ssl: true,
timeout: 15_000,
retry_linear_backoff: [delay: 150, factor: 2, tries: 3]
config :bolt_sips, Bolt,
hostname: 'localhost',
basic_auth: [username: "neo4j", password: "*********"],
port: 7687,
pool_size: 5,
max_overflow: 1
Sample code:
opts = Application.get_env(:bolt_sips, Bolt)
{:ok, _pid} = Bolt.Sips.start_link(opts)
conn = Bolt.Sips.conn
Bolt.Sips.query!(conn, "CREATE (a:Person {name:'Bob'})")
Bolt.Sips.query!(conn, "MATCH (a:Person) RETURN a.name AS name")
|> Enum.map(&(&1["name"]))
In the future we may use the DBConnection
framework.