mschae / boltex

Elixir driver for the neo4j bolt protocol
Other
29 stars 6 forks source link

[WIP] OTP app. #9

Closed vic closed 7 years ago

vic commented 7 years ago

Hey! I'm working on making Boltex a bit more useful as a Neo4j client.

Here's my work-in-progress otp_app branch.

Currently this is what you'd have to do for using the new Boltex.Client

# config.ex
config :boltex, MyClient, 
   host: "localhost", port: 7687, user: "neo4j", password: "password"

# my_app/bolt_client.ex
defmodule MyClient do
   use Boltex.Client
end

# then use the client to execute some cypher statements
{:ok, %{ "x" => %Boltex.Node{} }} = MyClient.run("CREATE (x) RETURN x")

See the tests on client_test.exs for some code examples. Also added a neo4j tag on these client tests. Tests requiring the server are ignored by default but you can enable them with mix test --include neo4j you will need a neo4j bolt server on localhost with credentials: neo4j/password - already configured travis ci for this -

https://travis-ci.org/vic/boltex/builds/171749809

florinpatrascu commented 7 years ago

Just curious and I apologize for not seeing the grander schema here. Why would you add more complexity to Boltex, rather than keep it simple, as close to the "metal" as possible?! It seems to me that your approach with this PR is almost overlapping with mine: Bolt.Sips - https://github.com/florinpatrascu/bolt_sips. As I've said, I am just curious to see where Boltex is going and eventually extract the functionality I need out of it, before it is becoming more complex than I need for my project. Thank you!

vic commented 7 years ago

@florinpatrascu oh, didn't know you were already working on bolt_sips it's just that I wanted to use bolt for a project of mine and it seemed to be very basic (being Boltex.test the only way documented way to interact with the server), but you have a point on keeping boltex a simple bolt-protocol interface. So maybe I'll just end using your client :) will have to take a look at it. Feel free to close this PR if you are unwilling to add this to boltex itself.

mschae commented 7 years ago

@vic thanks for your hard work on this. I agree that the ways to interact with the server are very limited at this point, hopefully I can merge my DBConnection branch soon, I was waiting for their stable release. That will then be the officially suggested way of interacting with the server.

Unfortunately I am going to have to close this PR (as you suggested) for the following reason: the scope of this project was solely to provide a driver. For a full-blown OTP implementation I'd like to keep a layer of separation between the driver and the app. I believe this separation works very will with Postgrex/Ecto. That's why I'm enforcing it here.

Do feel free to use @florinpatrascu's brilliant implementation or breaking yours out into its own package. I do intend to keep working on this project and providing the best possible driver for neo4j.

florinpatrascu commented 7 years ago

Thank you both for shedding light on this, and thank you again for all the work you guys put in this. Michael, I am looking forward to seeing the DBConnection added to Boltex, when your time permit, and I'll refactor bolt_sips to using it, for pooling; currently using a poolboy based own solution. Vic, if your time allow, please poke around bolt_sips and see if you can use it for your projects. I welcome any feedback, and especially critique;) I'll be away today for a part of the day but I'll reply later with any feedback, if need be. Thanks again all, and have a nice weekend!

vic commented 7 years ago

@mschae +1 for adding DBConnection to boltex. I'm definitely going to try @florinpatrascu's bolt_sips :)

mschae commented 7 years ago

Finally had some time to work with db_connection. Please try it out: #11