Skip to content

[Feature]: Support multiple RDBMS for background jobs persistence #631

Open
Ismaellima4 wants to merge 8 commits into
rapina-rs:mainfrom
Ismaellima4:feat/support-multiple-rdbms-for-background-jobs-persistence
Open

[Feature]: Support multiple RDBMS for background jobs persistence #631
Ismaellima4 wants to merge 8 commits into
rapina-rs:mainfrom
Ismaellima4:feat/support-multiple-rdbms-for-background-jobs-persistence

Conversation

@Ismaellima4

Copy link
Copy Markdown
Contributor

Summary

What does this PR do?

Extract backend-specific SQL into dedicated structs (Postgres, Mysql, Sqlite)
and dispatch via match on DbBackend instead of hardcoding PostgreSQL.

Migration:

  • Remove gen_random_uuid(), DEFAULT now(), DEFAULT '{}' — application supplies all values
  • Conditional index: partial for Postgres, regular for MySQL, skip for SQLite

Model:

  • Manual FromQueryResult — try native Uuid first, then String + parse (SQLite stores UUIDs as TEXT)

Backend extraction (backend.rs):

  • build_insert_stmt, build_retry_stmt, build_fail_stmt, build_success_stmt, claim_batch per backend
  • mod.rs / retry.rs / worker.rs dispatch via match on DbBackend

Related Issues

Closes #430

Checklist

  • cargo fmt passes
  • cargo clippy has no warnings
  • Tests pass
  • Documentation updated (if needed)

Extract backend-specific SQL into dedicated structs (Postgres, Mysql,
Sqlite)
and dispatch via match on DbBackend instead of hardcoding PostgreSQL.

Migration:
- Remove gen_random_uuid(), DEFAULT now(), DEFAULT '{}' — application
  supplies all values
- Conditional index: partial for Postgres, regular for MySQL, skip for
  SQLite

Model:
- Manual FromQueryResult — try native Uuid first, then String + parse
  (SQLite stores UUIDs as TEXT)

Backend extraction (backend.rs):
- build_insert_stmt, build_retry_stmt, build_fail_stmt,
  build_success_stmt,
  claim_batch per backend
- mod.rs / retry.rs / worker.rs dispatch via match on DbBackend
@Ismaellima4 Ismaellima4 requested a review from arferreira as a code owner June 12, 2026 17:43
@github-actions github-actions Bot added the area: core Core framework label Jun 12, 2026
@arferreira arferreira requested review from ShiraiEd and arferreira and removed request for ShiraiEd and arferreira June 17, 2026 00:11
@arferreira arferreira added this to the 0.13.0 milestone Jun 17, 2026

@arferreira arferreira left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work so far, thanks! I pulled your branch and ran the SQlite e2e locally, looking great. I left some comments important to address before we merge, it might be better if you run against a real MySQL 8.

Comment thread rapina/src/jobs/backend.rs Outdated
Comment thread rapina/src/jobs/backend.rs Outdated
Comment thread rapina/src/jobs/create_rapina_jobs.rs Outdated
Comment thread rapina/src/jobs/mod.rs Outdated
Comment thread rapina/src/jobs/backend.rs Outdated
Comment thread rapina/src/jobs/create_rapina_jobs.rs
Ismaellima4 and others added 2 commits June 20, 2026 13:23
- MySQL claim_select: SELECT {id} instead of SELECT *
  (only the id column is needed)
- Add 9 backend-specific unit tests (SQL shape, params, value types)
- Remove trivial Uuid::new_v4() test
- Fix doc on accessors (explain &str vs to_string trade-off)
- Document json() vs json_binary() portability choice
@Ismaellima4 Ismaellima4 requested a review from arferreira June 20, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support multiple RDBMS for background jobs persistence

2 participants