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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 10
37 changes: 33 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,43 @@ on:
branches: [main]
pull_request:

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
rust:
lint-test:
name: Lint, test, and package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- run: cargo fmt --check
- run: cargo clippy --all-targets -- -D warnings
- run: cargo test
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all --check
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo test --all-targets --all-features
- run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
- run: cargo package

msrv:
name: MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.85.0
- uses: Swatinem/rust-cache@v2
- run: cargo check --all-targets --all-features

dependencies:
name: Dependency policy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check
command-arguments: advisories bans licenses sources
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

env:
CARGO_TERM_COLOR: always

jobs:
release-plz:
name: Release-plz
runs-on: ubuntu-latest
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: release-plz/action@v0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
39 changes: 29 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
[package]
name = "absurd-rust-sdk"
version = "0.1.0"
edition = "2021"
edition = "2024"
rust-version = "1.85"
authors = ["Manuel Schiller"]
description = "Community Rust SDK for Absurd, a Postgres-native durable workflow system"
license = "Apache-2.0"
repository = "https://github.com/manuschillerdev/absurd-rust-sdk"
readme = "README.md"
keywords = ["absurd", "postgres", "workflow", "durable", "queue"]
categories = ["asynchronous", "database"]
include = ["Cargo.toml", "LICENSE", "README.md", "examples/**", "src/**", "tests/**"]

[lib]
name = "absurd_rust_sdk"
path = "src/lib.rs"

[dependencies]
chrono = { version = "0.4", features = ["serde"] }
deadpool-postgres = { version = "0.14", features = ["rt_tokio_1"] }
chrono = { version = "0.4", default-features = false, features = ["clock", "serde", "std"] }
deadpool-postgres = { version = "0.14", default-features = false, features = ["rt_tokio_1"] }
hostname = "0.4"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal", "sync", "time"] }
tokio-postgres = { version = "0.7", features = ["runtime", "with-chrono-0_4", "with-serde_json-1", "with-uuid-1"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "2.0"
tokio = { version = "1.21", features = ["macros", "rt-multi-thread", "signal", "sync", "time"] }
tokio-postgres = { version = "0.7", default-features = false, features = ["runtime", "with-chrono-0_4", "with-serde_json-1", "with-uuid-1"] }
tracing = "0.1"
uuid = { version = "1", features = ["serde", "v4"] }
uuid = { version = "1.0", default-features = false, features = ["serde", "std", "v4"] }

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
tokio = { version = "1.21", features = ["macros", "rt-multi-thread", "time"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[lints.rust]
future_incompatible = { level = "deny", priority = -1 }
nonstandard_style = { level = "deny", priority = -1 }
rust_2018_idioms = { level = "deny", priority = -1 }
unsafe_code = "forbid"

[lints.clippy]
all = { level = "deny", priority = -1 }
cargo = { level = "deny", priority = -1 }
dbg_macro = "deny"
expect_used = "deny"
multiple_crate_versions = "allow"
panic = "deny"
todo = "deny"
unimplemented = "deny"
unwrap_used = "deny"
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ Next hardening targets:

Environment resolution uses `ABSURD_DATABASE_URL`, then `DATABASE_URL`, then `PGDATABASE`, then `postgresql://localhost/absurd`.

## Development

The crate targets Rust 1.85+ and edition 2024.

```sh
cargo fmt --all --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-targets --all-features
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
cargo deny check advisories bans licenses sources
cargo package
```

`Cargo.lock` is intentionally not committed because this is a library crate; CI resolves the current compatible dependency graph and Dependabot tracks manifest/action updates.

## License

Apache-2.0
24 changes: 24 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[advisories]
ignore = []

[licenses]
allow = [
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"BSL-1.0",
"MIT",
"Unicode-3.0",
"Zlib",
]
confidence-threshold = 0.8

[bans]
highlight = "all"
multiple-versions = "warn"
wildcards = "deny"

[sources]
allow-git = []
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
unknown-git = "deny"
unknown-registry = "deny"
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "stable"
components = ["clippy", "rustfmt"]
profile = "minimal"
4 changes: 4 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
edition = "2024"
newline_style = "Unix"
use_field_init_shorthand = true
use_try_shorthand = true
8 changes: 4 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::context::TaskContext;
use crate::error::{map_database_error, Error, Result};
use crate::error::{Error, Result, map_database_error};
use crate::executor::execute_claimed_catching;
use crate::task::Task;
use crate::types::{
duration_seconds_ceil, validate_queue_name, CancellationPolicy, ClaimedTask, CleanupResult,
Json, SpawnOptions, SpawnResult, TaskOptions, WorkBatchOptions, WorkerOptions,
CancellationPolicy, ClaimedTask, CleanupResult, Json, SpawnOptions, SpawnResult, TaskOptions,
WorkBatchOptions, WorkerOptions, duration_seconds_ceil, validate_queue_name,
};
use crate::worker::Worker;
use deadpool_postgres::{Config as PoolConfig, Pool, Runtime};
use serde::{de::DeserializeOwned, Serialize};
use serde::{Serialize, de::DeserializeOwned};
use serde_json::Value;
use std::collections::HashMap;
use std::future::Future;
Expand Down
6 changes: 3 additions & 3 deletions src/context.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::error::{map_database_error, Error, Result};
use crate::types::{duration_seconds_ceil, ClaimedTask, Json};
use crate::error::{Error, Result, map_database_error};
use crate::types::{ClaimedTask, Json, duration_seconds_ceil};
use chrono::{DateTime, Utc};
use deadpool_postgres::Pool;
use serde::{de::DeserializeOwned, Serialize};
use serde::{Serialize, de::DeserializeOwned};
use serde_json::{Map, Value};
use std::collections::{HashMap, HashSet};
use std::future::Future;
Expand Down
2 changes: 1 addition & 1 deletion src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::client::{RegisteredTask, TaskHandler};
use crate::context::TaskContext;
use crate::error::{map_database_error, Error, Result};
use crate::error::{Error, Result, map_database_error};
use crate::types::{ClaimedTask, Json, UnknownTaskPolicy};
use deadpool_postgres::Pool;
use serde_json::json;
Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::error::{Error, Result};
use serde_json::{json, Map, Value};
use serde_json::{Map, Value, json};
use std::time::Duration;
use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion src/worker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::client::{claim_tasks, RegisteredTask};
use crate::client::{RegisteredTask, claim_tasks};
use crate::error::{Error, Result};
use crate::executor::execute_claimed_catching;
use crate::types::WorkerOptions;
Expand Down
Loading
Loading