rust-teos
rust-teos copied to clipboard
Use `sqlx` inplace of `rusqlite`
This PR replaces the rusqlite
SQLite engine with sqlx
.
sqlx
is an asynchronous versatile sql engine that supports both SQLite & PostgreSQL.
Due to the asynchronous-only nature of sqlx
, every method that interacted with the DB had to be asynchronous as well. This ripple effect propagated to nearly all the methods of the tower components. Also to the lightning::chain::Listen
trait, thus a new AsyncListen
trait was introduced to replace it.
The sqlite driver is enabled with the sqlite
feature, and the postgresql driver with the postgres
feature.
By default, both of them are enabled, meaning that the tower program can run on top of either a sqlite or postgresql db.
To enable postgres-only driver: cargo build --no-default-features --features postgres
(replace postgres
with sqlite
for sqlite-only build)
Fixes #32
To test the tower with postgresql DB, this docker compose script might be handy:
version: '3.1'
services:
db:
image: postgres
restart: always
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: pass
POSTGRES_USER: user
POSTGRES_DB: teos