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

Support for DBConnection #3

almightycouch opened this Issue Apr 19, 2016 · 4 comments


None yet
3 participants

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


This comment has been minimized.


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.


This comment has been minimized.


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"}]

This comment has been minimized.

hamiltop commented Jul 9, 2016

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


This comment has been minimized.


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 join this conversation on GitHub. Already have an account? Sign in to comment