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
63 changes: 34 additions & 29 deletions .github/workflows/audit.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: Security audit
on:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"
push:
branches: [main, develop]
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/deny.toml'
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/deny.toml"

pull_request:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/deny.toml'
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/deny.toml"
workflow_call:


jobs:
cargo-audit:
Expand All @@ -29,30 +28,36 @@ jobs:
key: cargo-audit-${{ runner.os }}
- run: cargo install cargo-audit --locked --force
- run: cargo audit --ignore RUSTSEC-2024-0436 #(used in ratatui)

cargo-vet:
runs-on: ubuntu-latest
env:
CARGO_VET_VERSION: 0.10.1
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable
- uses: actions/cache@v6
with:
path: ${{ runner.tool_cache }}/cargo-vet
key: cargo-vet-bin-${{ env.CARGO_VET_VERSION }}
- name: Add the tool cache directory to the search path
run: echo "${{ runner.tool_cache }}/cargo-vet/bin" >> $GITHUB_PATH
- name: Ensure that the tool cache is populated with the cargo-vet binary
run: cargo install --root ${{ runner.tool_cache }}/cargo-vet --version ${{ env.CARGO_VET_VERSION }} cargo-vet
- name: Generate Lockfile
run: cargo generate-lockfile
- name: Invoke cargo-vet
run: cargo vet --locked
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable
- uses: actions/cache@v6
with:
path: ${{ runner.tool_cache }}/cargo-vet
key: cargo-vet-bin-${{ env.CARGO_VET_VERSION }}
- name: Add the tool cache directory to the search path
run: echo "${{ runner.tool_cache }}/cargo-vet/bin" >> $GITHUB_PATH
- name: Ensure that the tool cache is populated with the cargo-vet binary
run: cargo install --root ${{ runner.tool_cache }}/cargo-vet --version ${{ env.CARGO_VET_VERSION }} cargo-vet
- name: Generate Lockfile
run: cargo generate-lockfile
- name: Invoke cargo-vet
run: cargo vet --locked

cargo-deny:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: EmbarkStudios/cargo-deny-action@v2
- uses: actions/checkout@master
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v6
with:
path: ~/.cargo/bin/cargo-deny
key: cargo-deny-${{ runner.os }}
- run: cargo install cargo-deny --locked
- run: cargo deny check
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project are documented in this file.

## [Unreleased]

- *bump*: to v1.0.0-rc.12 ([#791](https://github.com/apalis-dev/apalis/pull/791))
- *bump*: to v1.0.0-rc.11 ([#790](https://github.com/apalis-dev/apalis/pull/790))
- **fix(core)**: wake idle workers when monitor shutdown starts ([#777](https://github.com/apalis-dev/apalis/pull/777))
- *bump*: to v1.0.0-rc.10 ([#775](https://github.com/apalis-dev/apalis/pull/775))
Expand Down
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apalis-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "apalis-core"
version = "1.0.0-rc.11"
version = "1.0.0-rc.12"
authors = ["Njuguna Mureithi <mureithinjuguna@gmail.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
20 changes: 10 additions & 10 deletions apalis-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ Specific documentation for tasks can be found in the [`task`] and [`task::builde

##### Relevant Guides:

- [**Defining Task arguments**](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/task_fn/guide/index.html) - Creating effective task arguments that are scalable and type-safe
- [**Defining Task arguments**](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/task_fn/guide/index.html) - Creating effective task arguments that are scalable and type-safe

### Backends

The [`Backend`](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/backend/trait.Backend.html) trait serves as the core abstraction for all task sources.
The [`Backend`](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/backend/trait.Backend.html) trait serves as the core abstraction for all task sources.
It defines task polling mechanisms, streaming interfaces, and middleware integration points.

<details>
Expand All @@ -68,16 +68,16 @@ It defines task polling mechanisms, streaming interfaces, and middleware integra

#### Inbuilt Implementations

- [`MemoryStorage`](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/backend/memory/struct.MemoryStorage.html) : In-memory storage based on channels
- [`Pipe`](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/backend/pipe/index.html) : Pipe-based backend for a stream-to-backend pipeline
- [`CustomBackend`](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/backend/custom/index.html) : Flexible backend composition allowing custom functions for task management
- [`MemoryStorage`](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/backend/memory/struct.MemoryStorage.html) : In-memory storage based on channels
- [`Pipe`](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/backend/pipe/index.html) : Pipe-based backend for a stream-to-backend pipeline
- [`CustomBackend`](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/backend/custom/index.html) : Flexible backend composition allowing custom functions for task management

Backends handle task persistence, distribution, and reliability concerns while providing
a uniform interface for worker consumption.

### Workers

The [`Worker`](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/worker/index.html) is the core runtime component responsible for task polling, execution, and lifecycle management:
The [`Worker`](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/worker/index.html) is the core runtime component responsible for task polling, execution, and lifecycle management:

#### Worker Lifecycle

Expand All @@ -94,7 +94,7 @@ The following are the main components the worker module:
- [`Worker`] - Actual worker implementation that processes tasks
- [`WorkerContext`] - Runtime state including task counts and execution status
- [`Event`] - Worker event enumeration (`Start`, `Engage`, `Idle`, `Error`, `Stop`)
- [`Ext`](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/worker/ext/index.html) - Extension traits and middleware for adding functionality to workers
- [`Ext`](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/worker/ext/index.html) - Extension traits and middleware for adding functionality to workers

#### Example: Building and Running a Worker

Expand Down Expand Up @@ -129,11 +129,11 @@ Learn more about workers in the [`worker`](crate::worker) and [`worker::builder`
##### Relevant Tutorials:

- [**Creating task handlers**](crate::task::task_fn) - Defining task processing functions using the [`TaskFn`] trait
- [**Testing task handlers with `TestWorker`**](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/worker/test_worker/index.html) - Specialized worker implementation for unit and integration testing
- [**Testing task handlers with `TestWorker`**](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/worker/test_worker/index.html) - Specialized worker implementation for unit and integration testing

### Monitor

The [`Monitor`](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/monitor/struct.Monitor.html) helps manage and coordinate multiple workers:
The [`Monitor`](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/monitor/struct.Monitor.html) helps manage and coordinate multiple workers:

**Main Features:**

Expand Down Expand Up @@ -166,7 +166,7 @@ async fn main() {
}
```

Learn more about the monitor in the [`monitor` module](https://docs.rs/apalis-core/1.0.0-rc.11/apalis_core/monitor/index.html.
Learn more about the monitor in the [`monitor` module](https://docs.rs/apalis-core/1.0.0-rc.12/apalis_core/monitor/index.html.

### Middleware

Expand Down
95 changes: 95 additions & 0 deletions apalis-core/src/backend/ext/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,5 +317,100 @@ macro_rules! delegate_expose {
$wrap_body
}
}

impl<$($lt,)* $($generic),+> ListQueues for $wrapper
where
B: ListQueues + Send + Sync,
$($bound)+
{
async fn list_queues(
&self,
) -> Result<Vec<QueueInfo>, Self::Error> {
let $result = self.$field.list_queues().await;
#[allow(unused_variables)]
let $this = &*self;
$wrap_body
}
}

impl<$($lt,)* $($generic),+> ListWorkers for $wrapper
where
B: ListWorkers + Send + Sync,
$($bound)+
{
async fn list_workers(
&self,
) -> Result<Vec<RunningWorker>, Self::Error> {
let $result = self.$field.list_workers().await;
#[allow(unused_variables)]
let $this = &*self;
$wrap_body
}

async fn list_all_workers(
&self,
) -> Result<Vec<RunningWorker>, Self::Error> {
let $result = self.$field.list_all_workers().await;
#[allow(unused_variables)]
let $this = &*self;
$wrap_body
}
}

impl<$($lt,)* $($generic),+> ListTasks for $wrapper
where
B: ListTasks + Send + Sync,
$($bound)+
{
async fn list_tasks(
&self,
filter: &Filter,
) -> Result<Vec<Task<Self::Compact>>, Self::Error> {
let $result = self.$field.list_tasks(filter).await;
#[allow(unused_variables)]
let $this = &*self;
$wrap_body
}
}

impl<$($lt,)* $($generic),+> ListAllTasks for $wrapper
where
B: ListAllTasks + Send + Sync,
$($bound)+
{
async fn list_all_tasks(
&self,
filter: &Filter,
) -> Result<Vec<Task<Self::Compact>>, Self::Error> {
let $result = self.$field.list_all_tasks(filter).await;
#[allow(unused_variables)]
let $this = &*self;
$wrap_body
}
}

impl<$($lt,)* $($generic),+> Metrics for $wrapper
where
B: Metrics + Send + Sync,
$($bound)+
{
async fn global(
&self,
) -> Result<Vec<Statistic>, Self::Error> {
let $result = self.$field.global().await;
#[allow(unused_variables)]
let $this = &*self;
$wrap_body
}

async fn fetch_by_queue(
&self,
) -> Result<Vec<Statistic>, Self::Error> {
let $result = self.$field.fetch_by_queue().await;
#[allow(unused_variables)]
let $this = &*self;
$wrap_body
}
}
};
}
2 changes: 1 addition & 1 deletion apalis-core/src/backend/ext/inspect_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use futures_sink::Sink;
use futures_util::SinkExt;
use futures_util::TryStreamExt;

use crate::{backend::*, worker::context::WorkerContext};
use crate::{backend::*, task::Task, worker::context::WorkerContext};

/// A `Backend` wrapper that runs a callback `F` on each error yielded by the poll stream.
#[derive(Debug, Clone)]
Expand Down
Loading
Loading