-
Notifications
You must be signed in to change notification settings - Fork 6
Bolt v3 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dominique-vassard
wants to merge
12
commits into
mschae:master
Choose a base branch
from
dominique-vassard:bolt_v3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Bolt v3 #27
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
457fcdb
Implement INIT message
dominique-vassard a1f5740
Implement new RUN format
dominique-vassard badc2c8
Implement new transaction message: BEGIN, COMMIT, ROLLBACK + Add Meta…
dominique-vassard 340001c
Implement GOODBYE message
dominique-vassard 31528a0
Fix tests
dominique-vassard 4d8d429
VersionAgent is now supervised to avoid error when non already started
dominique-vassard cd062b6
Generalize useage of %Boltex.Metadata{}
dominique-vassard bbf1623
Add neo4j 3.5 to test environments
dominique-vassard b20efe0
use Agent is not available in 1.3 nor 1.4
dominique-vassard 02f7614
server does not respond when there is bookmarks defined in medatada (…
dominique-vassard d8f81b9
Docs + bump version
dominique-vassard 347d700
Rebase + Add tests
dominique-vassard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| # BOLT V3 INFORMATION | ||
|
|
||
| Since Neo4j 3.5, boltv3 is here! | ||
|
|
||
| Nothing changes regarding types / structures, only messages are impacted. | ||
|
|
||
| ## Metadata | ||
| `Metadata` is a structure used as parameters by `RUN` and `BEGIN`. It is the same for both messages. | ||
| It purpose is not well defined yet. Needs research... | ||
|
|
||
| Name | type | description | ||
| -----|------|------------ | ||
| bookmarks | list(string) | A list of bookmarks to be used | ||
| tx_timeout | int | the query timeout (milliseconds) | ||
| tx_metadata | map | ? | ||
|
|
||
| ## HELLO | ||
| This message replaces `INIT` and serves the same purpose. | ||
|
|
||
| ### Required parameters | ||
| Name | type | description | ||
| -----|------|------------ | ||
| user_agent | string | similar to _client_name_ used in `INIT` | ||
| scheme | string | | | ||
| credentials | string | | | ||
| principal | string | | | ||
|
|
||
| #### Example | ||
| ``HELLO %{credentials: "password", principal: "neo4j", scheme: "basic", user_agent: "Boltex/0.5.0"}`` | ||
|
|
||
| ### Return | ||
| `SUCCESS` | ||
| or | ||
| `FAILURE` with an error string | ||
|
|
||
| When successfull, return contains the following data | ||
| Name | type | description | ||
| -----|------|------------ | ||
| server | string | The neo4j server version | ||
| connection_id | string || | ||
|
|
||
| #### Example | ||
| ``SUCCESS %{"connection_id" => "bolt-31", "server" => "Neo4j/3.5.1"}`` | ||
|
|
||
| ## RUN (Upated message) | ||
| `RUN` message still exists in bolt v1 and v2 and is used to send a query to the server. The server will respond with an acknowledglement and information about the result. Be aware that the result is not in the result. You have to send a `PULL_ALL` message to get the result. | ||
|
|
||
| ### Required parameters | ||
| Name | type | description | ||
| -----|------|------------ | ||
| _query | string | the query to be executed | ||
| _parameters | map | The parameters to be used by query | | ||
| _metadata | map | The metadata to be used (see metadata) | | ||
|
|
||
| #### Examples | ||
| ``"RETURN 1 as num" %{} %{}`` | ||
| ``"MATCH (:Person {uid: {uid}} RETURN p as person" %{uid: 5} %{tx_timeout: 5000}`` | ||
|
|
||
| ### Return | ||
| `SUCCESS` with data | ||
| or | ||
| `FAILURE` with an error string | ||
|
|
||
| When successfull, return contains the following data | ||
|
|
||
| Name | type | description | ||
| -----|------|------------ | ||
| fields | list(string) | fields that will be found in result | ||
| t_first | int | When the result will be available (replaces `result_available_after`) | ||
|
|
||
| #### Example | ||
| ``SUCCESS %{"fields" => ["num"], "t_first" => 0}`` | ||
|
|
||
| ## PULL_ALL (Upated message) | ||
| `PULL_ALL` message still exists in bolt v1 and v2 is used to fetch result from a previous `RUN` message. | ||
|
|
||
| ### Required parameters | ||
| None | ||
|
|
||
| #### Example | ||
| ``PULL_ALL`` | ||
|
|
||
| ### Return | ||
| multiple `RECORD` messages and a final `SUCCESS` | ||
| or | ||
| `FAILURE` with an error string | ||
|
|
||
| First, `PULL_ALL` will return `RECORD`s containing the query result. | ||
| When this stream is complete, it will return a `SUCCESS` message containing | ||
| Name | type | description | ||
| -----|------|------------ | ||
| bookmark | string | A bookmark name | ||
| stats | map | The stats summary (only for write operations) | ||
| t_last | int | time for result consumption (replaces `result_consumed_after`) | ||
| type | string | The operation type: **r**ead or **w**rite | ||
|
|
||
| Examples: | ||
| ``` | ||
| # Read | ||
| RECORD [1] | ||
| SUCCESS %{"bookmark" => "neo4j:bookmark:v1:tx16732", "t_last" => 0, "type" => "r"} | ||
|
|
||
| # Write | ||
| SUCCESS ~ %{"bookmark" => "neo4j:bookmark:v1:tx16733", "stats" => %{"labels-added" => 1, "nodes-created" => 1, "properties-set" => 2}, "t_last" => 0, "type" => "w"} | ||
| ``` | ||
|
|
||
| ## BEGIN | ||
| Signature: 0x11 | ||
|
|
||
| `BEGIN` starts a transaction. | ||
|
|
||
|
|
||
| ### Required parameters | ||
| Name | type | description | ||
| -----|------|------------ | ||
| _metadata | map | The metadata to be used (see metadata) | | ||
|
|
||
| #### Example | ||
| ``BEGIN %{}`` | ||
| ``BEGIN %{bookmarks: ["neo4j:bookmark:v1:tx111"]}`` | ||
|
|
||
| ### Return | ||
| `SUCCESS` message without data | ||
| or | ||
| `FAILURE` with an error string | ||
|
|
||
| #### Example | ||
| ``SUCCESS %{}`` | ||
|
|
||
| ## COMMIT | ||
| Signature: 0x12 | ||
|
|
||
| `COMMIT` commits the currently open transaction. | ||
|
|
||
| ### Required parameters | ||
| None | ||
|
|
||
| #### Example | ||
| ``COMMIT`` | ||
|
|
||
| ### Return | ||
| `SUCCESS` with data | ||
| or | ||
| `FAILURE` with an error string | ||
|
|
||
| When successfull, return contains the following data: | ||
|
|
||
| Name | type | description | ||
| -----|------|------------ | ||
| bookmark | string | A bookmark name | ||
|
|
||
| #### Example | ||
| ``SUCCESS %{"bookmark" => "neo4j:bookmark:v1:tx16732"}`` | ||
|
|
||
| ## ROLLBACK | ||
| Signature 0x13 | ||
|
|
||
| `ROLLBACK` rollbacks the currently open transaction. | ||
|
|
||
| ### Required parameters | ||
| None | ||
|
|
||
| #### Example | ||
| ``ROLLBACK`` | ||
|
|
||
| ### Return | ||
| `SUCCESS` message without data | ||
| or | ||
| `FAILURE` with an error string | ||
|
|
||
| #### Example | ||
| ``SUCCESS %{}`` | ||
|
|
||
| ## GOODBYE | ||
| Signature: 0x02 | ||
|
|
||
| `GOODBYE` closes the open connection | ||
|
|
||
| ### Required parameters | ||
| None | ||
|
|
||
| #### Example | ||
| ``GOODBYE`` | ||
|
|
||
| ### Return | ||
| Nothing because connection is closed. Server doesn't sent anything back! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,33 @@ defmodule Boltex do | |
| # | ||
| # It supports de- and encoding of Boltex binaries and sending and receiving | ||
| # of data using the Bolt protocol. | ||
|
|
||
| use Application | ||
| alias Boltex.Bolt | ||
|
|
||
| # def start_link(opts) do | ||
| # Supervisor.start_link(__MODULE__, opts, name: __MODULE__) | ||
| # end | ||
|
|
||
| # @impl true | ||
| # def init(_args) do | ||
| # children = [ | ||
| # Boltex.VersionAgent | ||
| # ] | ||
|
|
||
| # Supervisor.init(children, strategy: :one_for_one) | ||
| # end | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's delete everything that's commented out. |
||
|
|
||
| def start(_type, _args) do | ||
| import Supervisor.Spec | ||
|
|
||
| children = [ | ||
| worker(Boltex.VersionAgent, []) | ||
| ] | ||
|
|
||
| opts = [strategy: :one_for_one, name: __MODULE__] | ||
| Supervisor.start_link(children, opts) | ||
| end | ||
|
|
||
| @doc """ | ||
| A simple function to test the library | ||
|
|
||
|
|
@@ -23,8 +47,15 @@ defmodule Boltex do | |
| def test(host, port, query, params \\ %{}, auth \\ {}) do | ||
| {:ok, p} = :gen_tcp.connect(host, port, active: false, mode: :binary, packet: :raw) | ||
|
|
||
| :ok = Bolt.handshake(:gen_tcp, p) | ||
| {:ok, _info} = Bolt.init(:gen_tcp, p, auth) | ||
| {:ok, version} = Bolt.handshake(:gen_tcp, p) | ||
|
|
||
| case version do | ||
| 3 -> | ||
| {:ok, _info} = Bolt.hello(:gen_tcp, p, auth) | ||
|
|
||
| _ -> | ||
| {:ok, _info} = Bolt.init(:gen_tcp, p, auth) | ||
| end | ||
|
|
||
| Bolt.run_statement(:gen_tcp, p, query, params) | ||
| end | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this merits a new major version.