mirror of
https://github.com/Diggsey/sqlxmq.git
synced 2024-11-22 00:01:00 +00:00
Add CI
This commit is contained in:
parent
37f70afa33
commit
23010c9512
4 changed files with 140 additions and 5 deletions
24
.github/workflows/publish.yml
vendored
Normal file
24
.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
name: Publish
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: login
|
||||
args: -- ${{secrets.CARGO_TOKEN}}
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: publish
|
78
.github/workflows/toolchain.yml
vendored
Normal file
78
.github/workflows/toolchain.yml
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
on: [push, pull_request]
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
||||
fmt:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- run: rustup component add rustfmt
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: -- --check
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- run: rustup component add clippy
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
|
||||
test_nightly:
|
||||
name: Test (Nightly)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
|
@ -3,6 +3,10 @@ name = "sqlxmq"
|
|||
version = "0.1.0"
|
||||
authors = ["Diggory Blake <diggsey@googlemail.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/Diggsey/sqlxmq"
|
||||
description = "A reliable job queue using PostgreSQL as a backing store"
|
||||
readme = "README.md"
|
||||
|
||||
[workspace]
|
||||
members = ["sqlxmq_macros"]
|
||||
|
@ -12,13 +16,12 @@ members = ["sqlxmq_macros"]
|
|||
[dependencies]
|
||||
sqlx = { version = "0.5.1", features = [
|
||||
"postgres",
|
||||
"runtime-async-std-native-tls",
|
||||
"runtime-tokio-native-tls",
|
||||
"chrono",
|
||||
"uuid",
|
||||
] }
|
||||
tokio = { version = "1.3.0", features = ["full"] }
|
||||
dotenv = "0.15.0"
|
||||
futures = "0.3.13"
|
||||
chrono = "0.4.19"
|
||||
uuid = { version = "0.8.2", features = ["v4"] }
|
||||
log = "0.4.14"
|
||||
|
@ -29,3 +32,4 @@ sqlxmq_macros = { version = "0.1", path = "sqlxmq_macros" }
|
|||
[dev-dependencies]
|
||||
dotenv = "0.15.0"
|
||||
pretty_env_logger = "0.4.0"
|
||||
futures = "0.3.13"
|
||||
|
|
35
src/lib.rs
35
src/lib.rs
|
@ -110,13 +110,15 @@
|
|||
//! The first step is to define a function to be run on the job queue.
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::error::Error;
|
||||
//!
|
||||
//! use sqlxmq::{job, CurrentJob};
|
||||
//!
|
||||
//! // Arguments to the `#[job]` attribute allow setting default job options.
|
||||
//! #[job(channel_name = "foo")]
|
||||
//! async fn example_job(
|
||||
//! mut current_job: CurrentJob,
|
||||
//! ) -> sqlx::Result<()> {
|
||||
//! ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
||||
//! // Decode a JSON payload
|
||||
//! let who: Option<String> = current_job.json()?;
|
||||
//!
|
||||
|
@ -135,9 +137,22 @@
|
|||
//! Next we need to create a job runner: this is what listens for new jobs
|
||||
//! and executes them.
|
||||
//!
|
||||
//! ```rust
|
||||
//! ```rust,no_run
|
||||
//! use std::error::Error;
|
||||
//!
|
||||
//! use sqlxmq::JobRegistry;
|
||||
//!
|
||||
//! # use sqlxmq::{job, CurrentJob};
|
||||
//! #
|
||||
//! # #[job]
|
||||
//! # async fn example_job(
|
||||
//! # current_job: CurrentJob,
|
||||
//! # ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> { Ok(()) }
|
||||
//! #
|
||||
//! # async fn connect_to_db() -> sqlx::Result<sqlx::Pool<sqlx::Postgres>> {
|
||||
//! # unimplemented!()
|
||||
//! # }
|
||||
//!
|
||||
//! #[tokio::main]
|
||||
//! async fn main() -> Result<(), Box<dyn Error>> {
|
||||
//! // You'll need to provide a Postgres connection pool.
|
||||
|
@ -160,6 +175,7 @@
|
|||
//!
|
||||
//! // The job runner will continue listening and running
|
||||
//! // jobs until `runner` is dropped.
|
||||
//! Ok(())
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
@ -168,12 +184,25 @@
|
|||
//! The final step is to actually run a job.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # use std::error::Error;
|
||||
//! # use sqlxmq::{job, CurrentJob};
|
||||
//! #
|
||||
//! # #[job]
|
||||
//! # async fn example_job(
|
||||
//! # current_job: CurrentJob,
|
||||
//! # ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> { Ok(()) }
|
||||
//! #
|
||||
//! # async fn example(
|
||||
//! # pool: sqlx::Pool<sqlx::Postgres>
|
||||
//! # ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
||||
//! example_job.new()
|
||||
//! // This is where we override job configuration
|
||||
//! .set_channel_name("bar")
|
||||
//! .set_json("John")
|
||||
//! .set_json("John")?
|
||||
//! .spawn(&pool)
|
||||
//! .await?;
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
#[doc(hidden)]
|
||||
|
|
Loading…
Reference in a new issue