feat: expose public Postgres adapter API#259
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (16)
📝 WalkthroughWalkthroughThis PR introduces a stable, insert-focused public Rust API for external Postgres job enqueue adapters. It adds shared job preparation functions ( ChangesPublic Rust Postgres Enqueue Adapter API
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ef352ea to
f375d51
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/adr/016-rust-postgres-enqueue-adapter-api.md`:
- Line 38: The ADR/documentation refers to the accessor as `state_str` but the
canonical public bind accessor is `state_db_str()`; update the text and any code
examples in this document to consistently use `state_db_str()` (including
references around portable enum decoding and any sample calls or bindings), and
verify mentions of the accessor in related sections or examples match the
`state_db_str()` function name to prevent adapter implementation errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8b6214bb-aa89-4e3d-954c-bf4179bf56ae
📒 Files selected for processing (15)
README.mdawa-model/README.mdawa-model/migrations/v013_storage_auto_finalize.sqlawa-model/src/adapter.rsawa-model/src/bridge.rsawa-model/src/insert.rsawa-model/src/job.rsawa-model/src/lib.rsawa/src/lib.rsawa/tests/adapter_api_test.rsdocs/adr/016-bridge-adapters.mddocs/adr/016-rust-postgres-enqueue-adapter-api.mddocs/adr/017-python-transaction-bridging.mddocs/adr/README.mddocs/bridge-adapters.md
💤 Files with no reviewable changes (1)
- docs/adr/016-bridge-adapters.md
| The native sqlx path is not required to use this driver-friendly SQL. It may | ||
| keep a typed `PgExecutor` query that binds `JobState` directly and returns | ||
| `SELECT *`, while external adapters use `INSERT_JOB_SQL` with text casts and | ||
| `state_str` for portable enum decoding. |
There was a problem hiding this comment.
Use the canonical accessor name consistently (state_db_str).
Line 38 says state_str, but the documented/public bind accessor is state_db_str(). Please align this term to avoid adapter implementation errors.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/adr/016-rust-postgres-enqueue-adapter-api.md` at line 38, The
ADR/documentation refers to the accessor as `state_str` but the canonical public
bind accessor is `state_db_str()`; update the text and any code examples in this
document to consistently use `state_db_str()` (including references around
portable enum decoding and any sample calls or bindings), and verify mentions of
the accessor in related sections or examples match the `state_db_str()` function
name to prevent adapter implementation errors.
f375d51 to
b769de8
Compare
b769de8 to
66dc761
Compare
Summary
Expose a stable public Postgres insert-preparation contract for external Rust enqueue adapters.
awa::adapter::postgres/awa_model::adapter::postgresPreparedJobInsert,prepare_job_insert,prepare_raw_job_insertINSERT_JOB_SQLandUNIQUE_VIOLATION_SQLSTATEtokio-postgresbridge to use the public contractWhy
The SeaORM adapter review showed that exposing only a pool helper is not enough for real transactional enqueue. External Rust adapters need to execute the Awa insert through their own driver or transaction type, while still reusing Awa's validation, state selection, uniqueness, and ordering-key logic.
This API keeps Awa Postgres-only and avoids a premature generic adapter trait. Awa owns insert preparation and the SQL contract; adapter crates own driver-specific execution and row decoding.
Self-review
PreparedJobInserthas private fields and read-only getters, so callers cannot construct semantically invalid prepared inserts.state,priority,max_attempts,tags, andunique_states.tokio-postgresbridge now consumes the same public API external crates should use.PreparedRowwas private and future adapters required in-crate modules.Validation
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Tests