Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
384936c
feat: return job IDs from Worker::perform_later() for status tracking…
NewtTheWolf Sep 15, 2025
911d2b2
docs: add changelog entry for job ID feature
NewtTheWolf Sep 15, 2025
621312e
fix: add backticks to documentation for clippy
NewtTheWolf Sep 15, 2025
6e7e09f
Merge branch 'master' into feature/expose-worker-job-ids
kaplanelad Sep 21, 2025
4b26bbe
Merge branch 'master' into feature/expose-worker-job-ids
jondot Sep 27, 2025
e9718bf
Merge branch 'master' into feature/expose-worker-job-ids
kaplanelad Oct 8, 2025
4130b12
Merge branch 'master' into feature/expose-worker-job-ids
NewtTheWolf Oct 21, 2025
4b96876
Merge branch 'master' into feature/expose-worker-job-ids
NewtTheWolf Oct 27, 2025
5c94149
Merge branch 'master' into feature/expose-worker-job-ids
NewtTheWolf Dec 15, 2025
e8783da
Merge branch 'master' into feature/expose-worker-job-ids
NewtTheWolf Jan 12, 2026
5d24987
feat: expose tokio task id in BackgroundAsync worker mode
NewtTheWolf Jan 12, 2026
f051f76
feat: make Queue::get_jobs public for external job querying
NewtTheWolf Jan 12, 2026
9aa1973
feat: always return job ID from perform_later
NewtTheWolf Jan 12, 2026
be226b0
Merge branch 'master' into feature/expose-worker-job-ids
NewtTheWolf Feb 24, 2026
961be2c
fix: add missing errors doc for `Queue::get_jobs`
NewtTheWolf Feb 25, 2026
4a745de
feat: consistent ULID job IDs across all worker modes
NewtTheWolf Mar 9, 2026
54dd5df
Merge branch 'master' into feature/expose-worker-job-ids
NewtTheWolf Mar 9, 2026
e71299f
fix: correct import ordering for cargo fmt
NewtTheWolf Mar 9, 2026
7f08555
fix: add missing must_use attribute on AsyncJobTaskMap::remove
NewtTheWolf Mar 9, 2026
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Changelog



## Unreleased
- Fix `cargo fmt` error in `loco-new` ([#1669](https://github.com/loco-rs/loco/pull/1669))
- Fix UUID pattern in form field generation ([#1665](https://github.com/loco-rs/loco/pull/1665))
Expand All @@ -15,6 +14,7 @@
- Refactor users model to reuse `find_by_api_key` in `Authenticable` ([#1706](https://github.com/loco-rs/loco/pull/1706))
- Split error detail generic parameters ([#1709](https://github.com/loco-rs/loco/pull/1709))
- Update `loco-new` for new Rhai version ([#1704](https://github.com/loco-rs/loco/pull/1704))
- Feat: Worker::perform_later() now returns job IDs for status tracking. Returns `Result<Option<String>>` with the job ID when using background queue mode. [https://github.com/loco-rs/loco/issues/1623](https://github.com/loco-rs/loco/issues/1623)

### Breaking Changes
In file `src/initializers/view_engine.rs`, modify the code lines in `after_routes`:
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ storage_gcp = ["opendal/services-gcs"]
# Cache feature
cache_inmem = ["dep:moka"]
cache_redis = ["dep:bb8-redis", "dep:bb8"]
bg_redis = ["dep:redis", "dep:ulid"]
bg_pg = ["dep:sqlx", "dep:ulid"]
bg_sqlt = ["dep:sqlx", "dep:ulid"]
bg_redis = ["dep:redis"]
bg_pg = ["dep:sqlx"]
bg_sqlt = ["dep:sqlx"]
## Testing feature flags
integration_test = []
# Embed assets into binary
Expand Down Expand Up @@ -150,7 +150,7 @@ sqlx = { version = "0.8.2", default-features = false, features = [
"chrono",
"sqlite",
], optional = true }
ulid = { version = "1", optional = true }
ulid = "1"

# bg_redis: redis workers
redis = { version = "0.31", features = ["aio", "tokio-comp"], optional = true }
Expand Down
12 changes: 9 additions & 3 deletions docs-site/content/docs/processing/workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,19 @@ To use a worker, we mainly think about adding a job to the queue, so you `use` t

```rust
// .. in your controller ..
DownloadWorker::perform_later(
let job_id = DownloadWorker::perform_later(
&ctx,
DownloadWorkerArgs {
user_guid: "foo".to_string(),
},
)
.await
.await?;

// The job ID can be used for tracking job status
if let Some(id) = job_id {
println!("Job queued with ID: {}", id);
// You can store this ID to check job status later
}
```

Unlike Rails and Ruby, with Rust you can enjoy _strongly typed_ job arguments which gets serialized and pushed into the queue.
Expand Down Expand Up @@ -231,7 +237,7 @@ The `BackgroundWorker` trait is the core interface for defining background worke
- `queue() -> Option<String>`: Optional method to specify a custom queue for the worker (returns `None` by default).
- `tags() -> Vec<String>`: Optional method to specify tags for this worker (returns an empty vector by default).
- `class_name() -> String`: Returns the worker's class name (automatically derived from the struct name).
- `perform_later(ctx: &AppContext, args: A) -> Result<()>`: Static method to enqueue a job to be performed later.
- `perform_later(ctx: &AppContext, args: A) -> Result<Option<String>>`: Static method to enqueue a job to be performed later. Returns `Some(job_id)` when using background queue mode with a provider, `None` otherwise.

### Generate a Worker

Expand Down
Loading
Loading