Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[advisories]
ignore = [
# TODO(geofmureithi): track https://github.com/launchbadge/sqlx/issues/4082
"RUSTSEC-2023-0071",
"RUSTSEC-2025-0052",
"RUSTSEC-2024-0384",
]

[output]
quiet = false
deny = ["warnings"]
46 changes: 16 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ env:
DATABASE_URL: postgres://postgres:postgres@localhost/postgres

jobs:
defaults:
runs-on: ubuntu-latest
test:
name: Test Suite
runs-on: ${{ matrix.os }}
services:
postgres:
image: postgres:17
Expand All @@ -26,12 +27,9 @@ jobs:
--health-interval=10s
--health-timeout=5s
--health-retries=5
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest]
rust: [stable, beta]
include:
- os: ubuntu-latest
Expand Down Expand Up @@ -79,6 +77,18 @@ jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -100,30 +110,6 @@ jobs:
- name: Run cargo clippy
run: cargo clippy --all-targets --all-features

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}

- name: Build documentation
run: cargo doc --all-features --no-deps --document-private-items
env:
RUSTDOCFLAGS: "-Dwarnings"

security:
name: Security Audit
runs-on: ubuntu-latest
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,32 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
DATABASE_URL: postgres://postgres:postgres@localhost/postgres

jobs:

docs:
name: Build and Test Documentation
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@nightly

- name: Cache cargo registry
uses: actions/cache@v4
Expand Down
28 changes: 27 additions & 1 deletion .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ on:

env:
CARGO_TERM_COLOR: always
DATABASE_URL: postgres://postgres:postgres@localhost/postgres
RUST_BACKTRACE: 1

jobs:
quick-check:
name: Quick Check
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -67,6 +81,18 @@ jobs:
test-if-needed:
name: Test if Source Changed
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
needs: changes
if: needs.changes.outputs.src == 'true'
steps:
Expand Down Expand Up @@ -114,4 +140,4 @@ jobs:
fi
if [[ "${{ needs.changes.outputs.workflows }}" == "true" ]]; then
echo "- ⚙️ GitHub Actions workflows" >> $GITHUB_STEP_SUMMARY
fi
fi
15 changes: 14 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@ on:

env:
CARGO_TERM_COLOR: always
DATABASE_URL: postgres://postgres:postgres@localhost/postgres

jobs:
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -129,4 +142,4 @@ jobs:
draft: false
prerelease: ${{ contains(needs.validate.outputs.version, 'alpha') || contains(needs.validate.outputs.version, 'beta') || contains(needs.validate.outputs.version, 'rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "apalis-postgres"
version = "1.0.0-beta.1"
version = "1.0.0-beta.2"
authors = ["Njuguna Mureithi <[email protected]>"]
edition = "2024"
repository = "https://github.com/apalis-dev/apalis-postgres"
Expand All @@ -22,19 +22,19 @@ tokio-comp = ["tokio", "sqlx/runtime-tokio-rustls"]
tokio-comp-native-tls = ["tokio", "sqlx/runtime-tokio-native-tls"]

[dependencies]
apalis-core = { version = "1.0.0-beta.1", default-features = false, features = [
apalis-core = { version = "1.0.0-beta.2", default-features = false, features = [
"sleep",
"json",
] }
apalis-sql = { version = "1.0.0-beta.1", default-features = false }
serde = { version = "1", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"] }
apalis-sql = { version = "1.0.0-beta.2", default-features = false }
serde = { version = "1", features = ["derive"], default-features = false }
chrono = { version = "0.4", features = ["serde"], default-features = false }
pin-project = "1.1.10"
serde_json = "1"
futures = "0.3.30"
thiserror = "2"
tokio = { version = "1", features = ["rt", "net"], optional = true }
async-std = { version = "1.13.0", optional = true }
tokio = { version = "1", features = ["rt", "net"], optional = true, default-features = false}
async-std = { version = "1.13.0", optional = true, default-features = false}
ulid = { version = "1", features = ["serde"] }


Expand All @@ -46,6 +46,6 @@ features = ["chrono", "postgres", "json"]
[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
once_cell = "1.19.0"
apalis = { version = "1.0.0-beta.1" }
apalis-workflow = { version = "0.1.0-beta.1" }
apalis = { version = "1.0.0-beta.2" }
apalis-workflow = { version = "0.1.0-beta.2" }
futures-util = "0.3.30"
25 changes: 24 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,36 @@ ignore = []

[licenses]
confidence-threshold = 0.8
allow = ["Apache-2.0", "BSD-3-Clause", "MIT", "Unicode-3.0"]
allow = [
"Apache-2.0",
"BSD-3-Clause",
"MIT",
"Unicode-3.0",
"Zlib",
"ISC",
"CDLA-Permissive-2.0",
]

[bans]
multiple-versions = "deny"
highlight = "all"
skip-tree = [
{ name = "windows_x86_64_msvc" },
{ name = "windows_x86_64_gnullvm" },
{ name = "windows_x86_64_gnu" },
{ name = "windows_i686_msvc" },
{ name = "windows_i686_gnullvm" },
{ name = "windows_i686_gnu" },
{ name = "windows_aarch64_msvc" },
{ name = "windows_aarch64_gnullvm" },
{ name = "windows-targets" },
{ name = "windows-sys" },
# TODO: @geofmureithi Investigate why these are causing issues possibly due to sqlx dependencies
{ name = "getrandom" },
{ name = "hashbrown" },
{ name = "rand" },
{ name = "rand_chacha" },
{ name = "rand_core" },
]

[sources]
Expand Down
8 changes: 4 additions & 4 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use futures::stream::{self, StreamExt};

#[tokio::main]
async fn main() {
let pool = PgPool::connect(&std::env::var("DATABASE_URL").unwrap())
.await
.unwrap();
let db = std::env::var("DATABASE_URL").unwrap();
let pool = PgPool::connect(&db).await.unwrap();
PostgresStorage::setup(&pool).await.unwrap();
let mut backend = PostgresStorage::new(&pool);

// Push some tasks as a stream
let mut start = 0usize;
let mut items = stream::repeat_with(move || {
start += 1;
Expand All @@ -24,7 +24,7 @@ async fn main() {
.take(10);
backend.push_all(&mut items).await.unwrap();

async fn send_reminder(item: usize, wrk: WorkerContext) -> Result<(), BoxDynError> {
async fn send_reminder(item: usize, _wrk: WorkerContext) -> Result<(), BoxDynError> {
if item % 3 == 0 {
println!("Reminding about item: {} but failing", item);
return Err("Failed to send reminder".into());
Expand Down
2 changes: 1 addition & 1 deletion examples/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn main() {
.take(20)
.collect::<Vec<_>>()
.await;
apalis_postgres::sink::push_tasks(pool, config, items)
apalis_postgres::sink::push_tasks(&pool, config, items)
.await
.unwrap();
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pub struct PgNotify {
ListWorkers => supported("List all workers registered with the backend", false),
ListTasks => supported("List all tasks in the backend", false),
}]
///
/// [`SharedPostgresStorage`]: crate::shared::SharedPostgresStorage
#[pin_project::pin_project]
pub struct PostgresStorage<
Args,
Expand Down
Loading
Loading