项目作者: Badiapp

项目描述 :
Bolt+Routing Neo4j Elixir driver using Bolt Sips
高级语言: Elixir
项目地址: git://github.com/Badiapp/bolt-routing-driver.git
创建时间: 2018-03-29T15:33:48Z
项目社区:https://github.com/Badiapp/bolt-routing-driver

开源协议:MIT License

下载


Bolt+Routing Driver

Bolt Routing Driver, the Bolt+Routing Neo4j driver that supports clustering for Elixir using bolt_sips.

It means that you can send a read query to the driver and using one of the load balancing strategies will forward it to a chosen core.

Quick example

  1. # We need to specify when we are sending a write query that will require to be sent to the leader
  2. iex> Bolt.RoutingDriver.write_query("CREATE (n:Person { name: 'Adrian' })")
  3. [debug] [Bolt.RoutingDriver] localhost:7687 query...
  4. {:ok,
  5. %{
  6. stats: %{"labels-added" => 1, "nodes-created" => 1, "properties-set" => 1},
  7. type: "w"
  8. }}
  9. # Then we can send read queries, that will be executed in a different follower each time
  10. iex> Bolt.RoutingDriver.read_query("MATCH (n:Person {name: 'Adrian'}) RETURN n")
  11. [debug] [Bolt.RoutingDriver] localhost:7688 query...
  12. {:ok,
  13. [
  14. %{
  15. "n" => %Bolt.Sips.Types.Node{
  16. id: 0,
  17. labels: ["Person"],
  18. properties: %{"name" => "Adrian"}
  19. }
  20. }
  21. ]}
  22. # Now, it will run in a different follower
  23. iex> Bolt.RoutingDriver.read_query("MATCH (n:Person {name: 'Eduard'}) RETURN n")
  24. [debug] [Bolt.RoutingDriver] localhost:7689 query...
  25. {:ok, []}

Installation

The package can be installed as:

1. Add bolt_routing_driver to your list of dependencies in mix.exs:

  1. def deps do
  2. [{:bolt_routing_driver, git: "https://github.com/Badiapp/bolt-routing-driver"}]
  3. end

2. Ensure bolt_routing_driver is started before your application:

  1. def application do
  2. [applications: [:bolt_routing_driver], mod: {Bolt.RoutingDriver.Application, []}]
  3. end

3. Set your configuration

Edit your config/config.exs and set the entry URL, and any bolt_sips config that you want to change, for example:

  1. config :bolt_sips, Bolt,
  2. url: "<YOUR ENTRY URL>"
  3. # Any bolt_sips config that you want to change
  4. bolt_sips: [
  5. basic_auth: [
  6. username: "<YOUR USERNAME>",
  7. password: "<YOUR PASSWORD>"
  8. ],
  9. pool_size: 10
  10. ]

Running locally

Clone the repository

  1. git@github.com:Badiapp/bolt-routing-driver.git

Install dependencies

  1. cd bolt-routing-driver
  2. mix deps.get

Credit