forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1/n][dialect_support]Generalize indexer code to support different sq…
…l dialects (MystenLabs#17167) ## Description This PR generalizes the code in `sui-indexer` crate such that different diesel backends can be enabled through feature flags when compiling. The default backend is still postgres which means nothing changes in terms of how we build our binaries today. 1. The most important thing is that we do all kinds of db operation through macros which are feature gated such that we only pull in relevant db specific dependencies. 2. In Cargo.toml by default we do not add any db specific dependencies but only pull them through features: 3. In `sui-indexer`, all instances of `diesel::PgConnection` are pulled with `postgres-feature` and similary all instances of `diesel::MySqlConnection` are pulled with `mysql-feature` 4. `run_query` and `run_query_async` are replaced with their corresponding macro invocations 5. We do not try to make other dependencies of `sui-indexer` generic in this PR. This includes `sui-graphql-rpc` which just works with `IndexerReader<PgConnection>` for now (in the future we will refactor read for other db backends but for now the focus is to get writes to be compatible first) 6. Usages of `#[Cached(..)]` had to be replaced with an explicit usage of `SizedCache` as this macro doesn't seem to work for functions which take type parameters. 7. Next: we are going to introduce migrations for mysql and build `sui-indexer` for mysql ## Test plan Running this locally works: `cargo run --bin sui-indexer -- --db-url "postgres://sadhansood:sadhansood@localhost/test" --rpc-client-url "<>" --fullnode-sync-worker --reset-db`
- Loading branch information
1 parent
66a3763
commit e305b4c
Showing
30 changed files
with
1,008 additions
and
638 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.