boltex v0.4.0 Boltex.Bolt
The Boltex.Bolt module handles the Bolt protocol specific steps (i.e. handshake, init) as well as sending and receiving messages and wrapping them in chunks.
It abstracts transportation, expecing the transport layer to define send/2 and recv/3 analogous to :gen_tcp.
Shared options
Functions that allow for options accept these default options:
recv_timeout
: The timeout for receiving a response from the Neo4J s server (default: 10000)
Summary
Functions
Implementation of Bolt’s ACK_FAILURE. It acknowledges a failure while keeping transactions alive
Initiates the handshake between the client and the server
Initialises the connection
Implementation of Bolt’s RESET message. It resets a session to a “clean” state
Runs a statement (most likely Cypher statement) and returns a list of the records and a summary
Sends a list of messages using the Bolt protocol and PackStream encoding
Unpacks (or in other words parses) a message
Functions
Implementation of Bolt’s ACK_FAILURE. It acknowledges a failure while keeping transactions alive.
See http://boltprotocol.org/v1/#message-ack-failure
Options
See “Shared options” in the documentation of this module.
Initiates the handshake between the client and the server.
Options
See “Shared options” in the documentation of this module.
Initialises the connection.
Expects a transport module (i.e. gen_tcp
) and a Port
. Accepts
authorisation params in the form of {username, password}.
Options
See “Shared options” in the documentation of this module.
Examples
iex> Boltex.Bolt.init :gen_tcp, port
{:ok, info}
iex> Boltex.Bolt.init :gen_tcp, port, {"username", "password"}
{:ok, info}
Receives data.
This function is supposed to be called after a request to the server has been made. It receives data chunks, mends them (if they were split between frames) and decodes them using PackStream.
When just a single message is received (i.e. to acknowledge a command), this function returns a tuple with two items, the first being the signature and the second being the message(s) itself. If a list of messages is received it will return a list of the former.
The same goes for the messages: If there was a single data point in a message said data point will be returned by itself. If there were multiple data points, the list will be returned.
The signature is represented as one of the following:
:success
:record
:ignored
:failure
Options
See “Shared options” in the documentation of this module.
Implementation of Bolt’s RESET message. It resets a session to a “clean” state.
See http://boltprotocol.org/v1/#message-reset
Options
See “Shared options” in the documentation of this module.
Runs a statement (most likely Cypher statement) and returns a list of the records and a summary.
Records are represented using PackStream’s record data type. Their Elixir
representation is a Keyword with the indexse :sig
and :fields
.
Options
See “Shared options” in the documentation of this module.
Examples
iex> Boltex.Bolt.run_statement("MATCH (n) RETURN n")
[
{:success, %{"fields" => ["n"]}},
{:record, [sig: 1, fields: [1, "Example", "Labels", %{"some_attribute" => "some_value"}]]},
{:success, %{"type" => "r"}}
]
Sends a list of messages using the Bolt protocol and PackStream encoding.
Messages have to be in the form of {[messages], signature}.