Skip to content

Commit

Permalink
Merge branch 'chore/v0.6.0' into renovate/crate-sqlx-vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
geofmureithi authored Aug 28, 2024
2 parents bbf1799 + 873a2ca commit 111c4bc
Show file tree
Hide file tree
Showing 103 changed files with 3,964 additions and 1,980 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
paths:
- 'packages/**'
- '.github/workflows/bench.yaml'
- 'benches/**'
name: Benchmark
jobs:
storageBenchmark:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ jobs:
# vX.Y.Z-foo is pre-release version
VERSION=${GITHUB_REF#refs/tags/v}
VERSION_NUMBER=${VERSION%-*}
PUBLISH_OPTS="--dry-run"
if [[ $VERSION == $VERSION_NUMBER ]]; then
PUBLISH_OPTS=""
fi
PUBLISH_OPTS=""
echo VERSION=${VERSION} >> $GITHUB_ENV
echo PUBLISH_OPTS=${PUBLISH_OPTS} >> $GITHUB_ENV
echo VERSION_NUMBER=${VERSION_NUMBER} >> $GITHUB_ENV
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/mysql.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
on:
push:
paths:
- "packages/apalis-sql/src/lib.rs"
- "packages/apalis-sql/mysql.rs"
- "packages/apalis-sql/src/migrations/mysql/**"
- "packages/apalis-sql/src/Cargo.toml"
- ".github/workflows/mysql.yaml"
pull_request:
paths:
- "packages/apalis-sql/src/lib.rs"
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/postgres.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
on:
push:
paths:
- "packages/apalis-sql/src/lib.rs"
- "packages/apalis-sql/postgres.rs"
- "packages/apalis-sql/src/migrations/postgres/**"
- "packages/apalis-sql/src/Cargo.toml"
- ".github/workflows/postgres.yaml"
pull_request:
paths:
- "packages/apalis-sql/src/lib.rs"
Expand Down Expand Up @@ -37,4 +30,4 @@ jobs:
toolchain: stable
override: true
- run: cargo test --no-default-features --features postgres,migrate,tokio-comp -- --test-threads=1
working-directory: packages/apalis-sql
working-directory: packages/apalis-sql
4 changes: 0 additions & 4 deletions .github/workflows/redis.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
on:
push:
paths:
- "packages/apalis-redis/**"
- ".github/workflows/redis.yaml"
pull_request:
paths:
- "packages/apalis-redis/**"
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/sqlite.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
on:
push:
paths:
- "packages/apalis-sql/src/lib.rs"
- "packages/apalis-sql/src/sqlite.rs"
- "packages/apalis-sql/src/migrations/sqlite/**"
- "packages/apalis-sql/src/Cargo.toml"
- ".github/workflows/sqlite.yaml"
pull_request:
paths:
- "packages/apalis-sql/src/lib.rs"
Expand All @@ -28,4 +21,4 @@ jobs:
toolchain: stable
override: true
- run: cargo test --no-default-features --features sqlite,migrate,tokio-comp -- --test-threads=1
working-directory: packages/apalis-sql
working-directory: packages/apalis-sql
76 changes: 27 additions & 49 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository = "https://github.com/geofmureithi/apalis"

[package]
name = "apalis"
version = "0.5.3"
version = "0.6.0-rc.5"
authors = ["Geoffrey Mureithi <[email protected]>"]
description = "Simple, extensible multithreaded background job processing for Rust"
edition.workspace = true
Expand All @@ -21,16 +21,6 @@ bench = false
[features]
default = ["tracing", "tokio-comp"]

## Include redis storage
redis = ["apalis-redis"]
## Include Postgres storage
postgres = ["apalis-sql/postgres"]
## Include SQlite storage
sqlite = ["apalis-sql/sqlite"]
## Include MySql storage
mysql = ["apalis-sql/mysql"]
## Include Cron functionality
cron = ["apalis-cron"]

## Support Tracing 👀
tracing = ["dep:tracing", "dep:tracing-futures"]
Expand All @@ -47,20 +37,12 @@ timeout = ["tower/timeout"]
limit = ["tower/limit"]
## Support filtering jobs based on a predicate
filter = ["tower/filter"]
## Captures panics in executions and convert them to errors
catch-panic = []
## Compatibility with async-std and smol runtimes
async-std-comp = [
"apalis-sql?/async-std-comp",
"apalis-redis?/async-std-comp",
"apalis-cron?/async-std-comp",
"async-std",
]
async-std-comp = ["async-std"]
## Compatibility with tokio and actix runtimes
tokio-comp = [
"apalis-sql?/tokio-comp",
"apalis-redis?/tokio-comp",
"apalis-cron?/tokio-comp",
"tokio",
]
tokio-comp = ["tokio"]

layers = [
"sentry",
Expand All @@ -70,34 +52,16 @@ layers = [
"timeout",
"limit",
"filter",
"catch-panic",
]

docsrs = ["document-features"]

[dependencies.apalis-redis]
version = "0.5.3"
optional = true
path = "./packages/apalis-redis"
default-features = false

[dependencies.apalis-sql]

version = "0.5.3"
features = ["migrate"]
optional = true
default-features = false
path = "./packages/apalis-sql"

[dependencies.apalis-core]
version = "0.5.3"
version = "0.6.0-rc.5"
default-features = false
path = "./packages/apalis-core"

[dependencies.apalis-cron]
version = "0.5.3"
optional = true
default-features = false
path = "./packages/apalis-cron"

[dependencies.document-features]
version = "0.2"
Expand All @@ -116,17 +80,24 @@ pprof = { version = "0.13", features = ["flamegraph"] }
paste = "1.0.14"
serde = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
apalis = { path = ".", features = ["redis", "sqlite", "postgres", "mysql"] }
apalis = { path = ".", features = ["limit"]}
apalis-redis = { path = "./packages/apalis-redis" }
apalis-sql = { path = "./packages/apalis-sql", features = [
"postgres",
"mysql",
"sqlite",
] }
redis = { version = "0.25.3", default-features = false, features = [
"script",
"aio",
"connection-manager",
"tokio-comp",
"script",
"aio",
"connection-manager",
] }

[dev-dependencies.sqlx]
version = "0.8.1"
default-features = false
features = ["chrono", "mysql", "sqlite", "postgres"]
features = ["chrono", "mysql", "sqlite", "postgres", "runtime-tokio"]


[[bench]]
Expand All @@ -150,9 +121,16 @@ members = [
"examples/axum",
"examples/prometheus",
"examples/tracing",
# "examples/rest-api",
"examples/async-std-runtime",
"examples/basics",
"examples/redis-with-msg-pack",
"examples/redis-deadpool",
"examples/redis-mq-example",
"examples/cron",
"examples/catch-panic",
"examples/graceful-shutdown",
"examples/unmonitored-worker",
"examples/fn-args",
]


Expand Down
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,43 +59,41 @@ To get started, just add to Cargo.toml

```toml
[dependencies]
apalis = { version = "0.5", features = ["redis"] } # Backends available: postgres, sqlite, mysql, amqp
apalis = { version = "0.6" }
apalis-redis = { version = "0.6" }
# apalis-sql = { version = "0.6", features = ["postgres"] } # or mysql, sqlite
```

## Usage

```rust
use apalis::prelude::*;
use apalis::redis::RedisStorage;
use apalis_redis::{RedisStorage, Config};
use serde::{Deserialize, Serialize};
use anyhow::Result;

#[derive(Debug, Deserialize, Serialize)]
struct Email {
to: String,
}

impl Job for Email {
const NAME: &'static str = "apalis::Email";
}

/// A function that will be converted into a service.
async fn send_email(job: Email, data: Data<usize>) -> Result<(), Error> {
/// execute job
Ok(())
}

#[tokio::main]
async fn main() -> Result<()> {
async fn main() -> {
std::env::set_var("RUST_LOG", "debug");
env_logger::init();
let redis_url = std::env::var("REDIS_URL").expect("Missing env variable REDIS_URL");
let storage = RedisStorage::new(redis).await?;
let conn = apalis_redis::connect(redis_url).await.expect("Could not connect");
let storage = RedisStorage::new(conn);
Monitor::new()
.register_with_count(2, {
WorkerBuilder::new(format!("email-worker"))
.data(0usize)
.with_storage(storage)
.backend(storage)
.build_fn(send_email)
})
.run()
Expand All @@ -122,17 +120,13 @@ async fn produce_route_jobs(storage: &RedisStorage<Email>) -> Result<()> {
## Feature flags

- _tracing_ (enabled by default) — Support Tracing 👀
- _redis_ — Include redis storage
- _postgres_ — Include Postgres storage
- _sqlite_ — Include SQlite storage
- _mysql_ — Include MySql storage
- _cron_ — Include cron job processing
- _sentry_ — Support for Sentry exception and performance monitoring
- _prometheus_ — Support Prometheus metrics
- _retry_ — Support direct retrying jobs
- _timeout_ — Support timeouts on jobs
- _limit_ — 💪 Limit the amount of jobs
- _filter_ — Support filtering jobs based on a predicate
- _catch-panic_ - Catch panics that occur during execution

## Storage Comparison

Expand Down
Loading

0 comments on commit 111c4bc

Please sign in to comment.