-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: add postgres support in addition to sqlite for recon #302
Conversation
6c5c588
to
60edf7e
Compare
- a bunch of sql modules now... - stopped using query! macros as they don't work for 2 backends. - refactored things try to share queries but still a lot of pg/sqlite specific stuff. tried to keep it in one place so it was easier to reason about. - pushed some store checks up to the callers (e.g. is left > right fencepost)
Some ugly macro use (hack-ro?) to run a test for all databases. The postgres tests only run if `PG_TESTS=1`. The intention being that we don't want `cargo test` to fail generally, but in CI we want to start a db and make sure things pass I also updated the bitswap Store trait to include put, as we were going to the blockstore directly before
Still need to sort out the concrete types bound to daemon in c1. Should be able to get a database trait to work, but the many bounds on sqlx has made it super tedious.. If I really can't get it right, we could move some setup to run() and branch building concrete pg/sql store instances so the types can be inferred rather than declared. Or we could use Box<dyn Store> etc and use dynamic lookup
60edf7e
to
fc028b5
Compare
8608ac6
to
91bab16
Compare
70f5137
to
a2a7aaf
Compare
I attempted to get the postgres tests/docker running in CI and didn't get the networking right, so I reverted this branch back to where it was and I'm going to make a new branch to follow up with that. |
#308 handles this. |
also increased sql connection timeout
also fix cwd bug for script
The services section will start the database and migrations will be applied when connecting. We could use the script someday if we use query! macros but we likely never will given we have multiple backends.
Which has now been incorporated into this branch... along with one more change to capture store related metrics on the API side. |
All
Store
tests run with postgres and sqlite. Postgres tests no-op unlessPG_TESTS=1
, so thatcargo test
still passes even if you haven't set up a docker postgres image. In CI we can run them all in order to make sure the postgres type/query handling is valid. Themake check-migrations-ci
command handles setting up the dbs, applying migrations, running tests (will duplicate some tests with the current make tests command but tries to use the same parameters to avoid rebuildling things), and then cleaning up.The database can be specified with
ceramic-one daemon --database-url $DB_URL
orCERAMIC_ONE_DATABASE_URL="..." ceramic-one daemon
. Postgres or sqlite will be chosen based on the URL prefix, and defaults to putting a sqlite file in the "default directory" (seeDaemonOpts::default_directory
).I also added
put()
to theiron_bitswap::Store
trait as we were going through the concrete struct before. I couldn't get away from using concrete types, so I select the database and then use generics to bind them to the flavors of trait we need. We should be able to simplify/consolidate some of these traits now that we rely on&self
rather than&mut self
in recon::Store, but this PR is already big.