Skip to content
This repository has been archived by the owner. It is now read-only.

Support for DBConnection #3

almightycouch opened this issue Apr 19, 2016 · 4 comments

Support for DBConnection #3

almightycouch opened this issue Apr 19, 2016 · 4 comments


Copy link

@ghost ghost commented Apr 19, 2016

Ecto 2.0 requires adapters to support DBConnection ( The support for DBConnection has already been implemented quiet well in my fork of the RethinkDB driver.

Still, some features are missing (SSL support) and i some tests (connection_test.exs) have to be adjusted/rewritten. I will also talk with @hamiltop to see if he agrees to make the change (I think having support for different pool libraries in the driver could be a good thing).

@almightycouch almightycouch added this to the Support for Ecto 2.x milestone Apr 19, 2016
Copy link

@Lida Lida commented Jul 7, 2016

Any progress on Ecto 2.0 support? Now that Phoenix 1.2 is out and requires Ecto 2.0 by default.

Copy link
Collaborator Author

@ghost ghost commented Jul 8, 2016

I have been working on Ecto 2 support for some time now. Currently, here what has been done so far:

  • Fork of :rethinkdb package to support DBConnection (using multiplexed connections).
  • Port of 1.x codebase to 2.x. (basically, most of the work is for connection pool integrating).
  • Better support for types such as Ecto.UUID and Ecto.DateTime.
  • Support for Ecto integration tests (only 1/3 currently passing).

I'm working on failing integration tests (only migrator.exs is 100% passing currently). The Ecto provided integration tests cover most of the edge cases I did not even thought about. So it might take a while until everything works as excepted.

Currently, you should be able to work with basic DB queries (changesets, insert, update, delete and their *_all counterparts). Ecto.preload/2 should also work as excepted.

I have swapped ecto_2 and master branch. This means that currently, the Ecto 2.x branch is master and 1.x is in the ecto_1 branch.

  • For using the adapter for Ecto 1.x, you should use the published hex package.
  • For using the adapter for Ecto 2.x, you should use the master branch as follow:
def deps do
  [{:rethinkdb_ecto, github: "almightycouch/rethinkdb_ecto"}]
Copy link

@hamiltop hamiltop commented Jul 9, 2016

Is your fork ready for a discussion of merging into the mainline?

Copy link
Collaborator Author

@ghost ghost commented Jul 11, 2016

Hi @hamiltop, The fork is ready to be merged without conflics.

All the tests are passing successfully with the exception of 5 tests in test/connection_test.exs which must be rewritten to work with the DBConnection behaviour. Some new test should also be written to test the connection pools.

There are a few implementation details that should be discussed thought:

  • The connection logic is implemented in the Multiplexer module.
    • Each connection has two processes, for sending and receiving (see recv_loop/2).
    • Calling send_recv/3 function blocks until the response is received (or connection timeout) without blocking the connection. This is done using and GenServer.reply/3.
    • Only the latest authentication method (server >= 2.3) has been implemented. Older authentication methods must be implemented if required.
  • To use a specific pool backend, pass the module to the :pool option:
    • Within a supervision tree: supervisor(MyApp.Repo, [[pool: DBConnection.Poolboy]])
    • For available options, check: DBConnection.start_link/2.
    • Default is DBConnection.Connection, :poolboy and :sbroker are optional dependencies.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants