Database connection behaviour and connection pool for Elixir database drivers
open sourceApache-2.0free
DBConnection is an Elixir library that gives database drivers a connection behaviour and a connection pool, handling transactions, prepare and execute, cursors and the client process's describe, encode and decode steps. It keeps the socket in a holder the client works on directly, so query data isn't copied between processes, shuts down a connection a client fails to check back in, and queues checkouts with the CoDel algorithm to reject requests under overload. Its README links a series of articles on building a database adapter with DBConnection and Ecto, and it includes an ownership pool used mainly in tests.
Problems it solves
- write a database driver for Elixir with connection pooling
- pool database connections in an Elixir app under load
- reject database requests cleanly when an Elixir connection pool is overloaded
Features
- Connection behaviour for transactions, prepare/execute and cursors
- Connection pool that queues checkouts with the CoDel algorithm
- Avoids copying query data by letting the client work on the socket directly
- Deadlines that terminate connections held too long
- Ownership pool for tests
