-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sqlite and MySql support for asynk (#141)
* possible impl with sqlx, we need to refactor dependencies and features and also probably need to make queries folder for `sqlite` and `mysql` * fix clippy xd * finally sqlite almost work, need help to debug something * deleting some expects * sqlite may work in workflow * stupid workflow work * plz work * plz work , think i have fixed * fix workflow , now will work :D * this should work * this will definitely work * clean up so it works incorrectly faster * okay that didn't work so idk what i'm doing here * if this works i'm dropping out of university * store uuid as text , so this way `PostgreSQL` schema will not change * fix comment * fix clippy * implement backend sqlx trait that allows better code * better implementation with enum variants * `Makefile` now creates `tests_sqlite` directory * make `asynk` tests use `.env` variables * drop unnecessary `drop` * query types as enum * fix clippy * fix fmt, my bad i had a missconf in my home computer xd * stupid mysql does not work anything , i hate it so much :/ * rework to make it work with MySQL * debugging issue : the issue is related to how a uniq task is inserted in MySQL backend * MySQL own mutex , why Mysql is so gae ? * fix clippy * split test jobs * fix build * fix github actions * do not run github actions twice * fix formatting build * another approach * tokio console debug * fixing workflow * fixing workflow again * i think i finally fixed * fixed \! * fixed \? * i am stupid now should be fixed :) * test blocking and fang derive error * add postgres service to blocking workflow * running async worker tests and blocking worker tests * cargo term color sqlite * change sqlx version to 0.6.3 and using Pool instead of Transactions * fix workflow for mysql * fix workflow * fix clippy, warns and mysql workflow * adress comments and fix workflow * fix mysql healthcheck * fix mysql healthcheck, yeap again * remove healthcheck * healthcheck is needed , plz work * plz just work :( * try to fix workflow * update workflow to use a non deprecated version * return an error instead of panicking with fock * deleting prints and updating comments * deleting unwraps or justifying them * README and moving each backend to separate files * final README * bump fang version and bump rust version * nit: added missing newline for consistency * update readme * bump fang version following semver * address ayrat issues * Fix/independent decoding (#149) * independent decoding * Postgres and Sqlite passing * fix unreachable pattern warn * delete vscode stuff * I think this may be a Rust compiler issue, but I fixed it so I will take it * fix clippy * relocate comment * remove `backend` field from `AsyncQueue` * fix clippy * worst clippy fix of all time * fmt fix * use variant NoBackend instead Option * fix clippy * delete dummy variant * changing sqlite and mysql migrations * sqlx uuid encoding and decoding for sqlite and postgres * delete uuid previous impl comment * fix retry_task impl * fix mysql timestamp precision * rework encoding Datime<Utc> for postgresql and sqlite * rework encoding Uuid for mysql * fix clippy * fix serde_json::Value decoding and encoding * README stuff * improving API * improving worker API --------- Co-authored-by: Dopplerian <[email protected]> Co-authored-by: Ayrat Badykov <[email protected]>
- Loading branch information
1 parent
4bb21c4
commit bcbb48d
Showing
76 changed files
with
2,263 additions
and
702 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,40 @@ name: Test and Build Rust | |
on: | ||
push: | ||
pull_request: | ||
types: [opened, reopened] | ||
schedule: | ||
# Check if it works with current dependencies (weekly on Wednesday 2:32 UTC) | ||
- cron: '32 2 * * 3' | ||
|
||
env : | ||
DATABASE_URL : postgres://postgres:postgres@localhost/fang | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
strategy: | ||
matrix: | ||
toolchain: | ||
- stable | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
|
||
- name: Setup Rust | ||
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | ||
|
||
|
||
- name: Run clippy | ||
run: cargo clippy --verbose --all-targets --all-features -- -D warnings | ||
|
||
test_postgres_blocking: | ||
name: Test blocking | ||
runs-on: ubuntu-latest | ||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
services: | ||
# Label used to access the service container | ||
|
@@ -35,67 +58,196 @@ jobs: | |
--health-timeout 5s | ||
--health-retries 5 | ||
strategy: | ||
matrix: | ||
toolchain: | ||
- stable | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
components: clippy | ||
override: true | ||
profile: minimal | ||
toolchain: stable | ||
|
||
- name: Run clippy | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --verbose --all-targets --all-features -- -D warnings | ||
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | ||
|
||
- name: Install diesel-cli | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: install | ||
args: diesel_cli --no-default-features --features "postgres" | ||
run: cargo install diesel_cli --no-default-features --features postgres | ||
|
||
- name: Setup Postgres db | ||
working-directory: ./fang/postgres_migrations | ||
run: diesel setup | ||
run: diesel setup --database-url "postgres://postgres:postgres@localhost/fang" | ||
|
||
- name: Run blocking tests | ||
run: cargo test "blocking::queue::postgres" --verbose --features blocking --color always -- --nocapture | ||
|
||
- name: Run blocking dirty tests | ||
run: cargo test "blocking::worker" --verbose --features blocking -- --ignored | ||
|
||
test_fang_derive_error: | ||
name: Test fang_derive_error | ||
runs-on: ubuntu-latest | ||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
strategy: | ||
matrix: | ||
toolchain: | ||
- stable | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Rust | ||
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | ||
|
||
- name: Run fang derive error tests | ||
run: cargo test "fang_derive_error" --verbose --color always -- --nocapture | ||
|
||
test_postgres: | ||
name: Test postgres | ||
runs-on: ubuntu-latest | ||
env: | ||
DATABASE_URL: postgres://postgres:postgres@localhost/fang | ||
CARGO_TERM_COLOR: always | ||
|
||
strategy: | ||
matrix: | ||
toolchain: | ||
- stable | ||
|
||
services: | ||
# Label used to access the service container | ||
postgres: | ||
# Docker Hub image | ||
image: postgres | ||
# Provide the password for postgres | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
# Set health checks to wait until postgres has started | ||
|
||
ports: | ||
- 5432:5432 | ||
|
||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
- name: Change working dir | ||
working-directory: ./../.. | ||
run: pwd | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Rust | ||
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | ||
|
||
- name: Install diesel-cli | ||
run: cargo install diesel_cli --no-default-features --features postgres | ||
|
||
- name: Setup Postgres db | ||
working-directory: ./fang/postgres_migrations | ||
run: diesel setup --database-url "postgres://postgres:postgres@localhost/fang" | ||
|
||
- name: Run tests | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --verbose --all-features | ||
run: cargo test "asynk::async_queue::postgres" --verbose --features asynk-postgres --color always -- --nocapture | ||
|
||
- name: Run worker tests | ||
run: cargo test "asynk::async_worker::async_worker_tests" --verbose --features asynk-postgres --color always -- --nocapture | ||
|
||
test_sqlite: | ||
name: Test sqlite | ||
runs-on: ubuntu-latest | ||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
strategy: | ||
matrix: | ||
toolchain: | ||
- stable | ||
|
||
- name: Run dirty tests | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --verbose --all-features -- --ignored | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Rust | ||
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | ||
|
||
- name: Install sqlite3 | ||
run: | | ||
sudo apt install -y sqlite3 | ||
sqlite3 fang.db "VACUUM;" | ||
mkdir tests_sqlite | ||
- name: Install diesel-cli | ||
run: cargo install diesel_cli --no-default-features --features sqlite | ||
|
||
- name: Setup Sqlite db | ||
working-directory: ./fang/sqlite_migrations | ||
run: diesel setup --database-url "sqlite3://../../../fang.db" | ||
|
||
- name: Run tests | ||
run: cargo test "asynk::async_queue::sqlite" --verbose --features asynk-sqlite -- --nocapture | ||
|
||
release: | ||
name: Release x86_64-unknown-linux-gnu | ||
runs-on: ubuntu-latest | ||
needs: test | ||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
strategy: | ||
matrix: | ||
toolchain: | ||
- stable | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
override: true | ||
profile: minimal | ||
target: x86_64-unknown-linux-gnu | ||
toolchain: stable | ||
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | ||
|
||
- name: Build release | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release --verbose --all-features --target x86_64-unknown-linux-gnu | ||
run: cargo build --release --verbose --all-features --target x86_64-unknown-linux-gnu | ||
|
||
test_mysql: | ||
name: Test mysql | ||
runs-on: ubuntu-latest | ||
env: | ||
DATABASE_URL: mysql://root:mysql@localhost/fang | ||
CARGO_TERM_COLOR: always | ||
|
||
strategy: | ||
matrix: | ||
toolchain: | ||
- stable | ||
|
||
services: | ||
# Label used to access the service container | ||
mysql: | ||
# Docker Hub image | ||
image: mysql:8.1 | ||
# Provide the password for postgres | ||
env: | ||
MYSQL_ROOT_PASSWORD: mysql | ||
MYSQL_DATABASE: fang | ||
# here we should check if mysql is ready, but this does not work | ||
options: >- | ||
--health-cmd "mysqladmin ping -h localhost -u root -pmysql" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 3306:3306 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Rust | ||
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | ||
|
||
- name: Install diesel-cli | ||
run: cargo install diesel_cli --no-default-features --features mysql | ||
|
||
- name: Setup MySQL db | ||
working-directory: ./fang/mysql_migrations | ||
run: diesel setup --database-url "mysql://root:[email protected]/fang" | ||
|
||
- name: Run tests | ||
run: cargo test "asynk::async_queue::mysql" --verbose --features asynk-mysql --color always -- --nocapture |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ Cargo.lock | |
docs/content/docs/CHANGELOG.md | ||
docs/content/docs/README.md | ||
fang.db | ||
tests_sqlite/ |
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.