Skip to content

Commit

Permalink
feat: Add extensions supports
Browse files Browse the repository at this point in the history
  • Loading branch information
leo91000 committed May 28, 2024
1 parent a4df80d commit 00bfd36
Show file tree
Hide file tree
Showing 10 changed files with 574 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ serde_json = "1.0.117"
serde_qs = "0.13.0"
thiserror = "1.0.61"
chrono = { version = "0.4.38", features = ["serde"] }
sqlx = { version = "0.7.4", features = ["chrono", "postgres", "json", "macros", "runtime-tokio"], default-features = false }
sqlx = { version = "0.7.4", features = [
"chrono",
"postgres",
"json",
"macros",
"runtime-tokio",
], default-features = false }
getset = "0.1.2"
tracing = "0.1.40"
once_cell = "1.19.0"
Expand Down Expand Up @@ -61,13 +67,20 @@ graphile_worker_ctx = { path = "./crates/ctx", version = "0.1.2" }
graphile_worker_migrations = { path = "./crates/migrations", version = "0.4.3", default-features = false }
graphile_worker_task_handler = { path = "./crates/task_handler", version = "0.4.1" }
graphile_worker_shutdown_signal = { path = "./crates/shutdown_signal", version = "0.3.2" }
graphile_worker_extensions = { path = "./crates/extensions", version = "0.1.2" }
chrono = { version = "0.4.38", features = ["serde"] }
futures = "0.3.30"
getset = "0.1.2"
num_cpus = "1.16.0"
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117"
sqlx = { version = "0.7.4", features = ["postgres", "json", "chrono", "macros", "runtime-tokio"], default-features = false }
sqlx = { version = "0.7.4", features = [
"postgres",
"json",
"chrono",
"macros",
"runtime-tokio",
], default-features = false }
thiserror = "1.0.61"
tracing = "0.1.40"
tokio = { version = "1.37.0", features = ["macros", "signal"] }
Expand Down
1 change: 1 addition & 0 deletions crates/ctx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readme = "README.md"

[dependencies]
graphile_worker_job = { path = "../job", version = "0.1.2" }
graphile_worker_extensions = { path = "../extensions", version = "0.1.2" }
getset.workspace = true
serde_json.workspace = true
sqlx.workspace = true
11 changes: 10 additions & 1 deletion crates/ctx/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use getset::Getters;
use graphile_worker_extensions::ReadOnlyExtensions;
use graphile_worker_job::Job;
use serde_json::Value;
use sqlx::PgPool;
Expand All @@ -10,15 +11,23 @@ pub struct WorkerContext {
pg_pool: PgPool,
job: Job,
worker_id: String,
extensions: ReadOnlyExtensions,
}

impl WorkerContext {
pub fn new(payload: Value, pg_pool: PgPool, job: Job, worker_id: String) -> Self {
pub fn new(
payload: Value,
pg_pool: PgPool,
job: Job,
worker_id: String,
extensions: ReadOnlyExtensions,
) -> Self {
WorkerContext {
payload,
pg_pool,
job,
worker_id,
extensions,
}
}
}
12 changes: 12 additions & 0 deletions crates/extensions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "graphile_worker_extensions"
version = "0.1.2"
edition = "2021"
license-file = "LICENSE.md"
description = "Extensions package for graphile_worker, a high performance Rust/PostgreSQL job queue"
homepage = "https://docs.rs/graphile_worker_crontab_types"
documentation = "https://docs.rs/graphile_worker_crontab_types"
repository = "https://github.com/leo91000/graphile_worker/crates/crontab_types"
keywords = []
categories = []
readme = "README.md"
18 changes: 18 additions & 0 deletions crates/extensions/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions crates/extensions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Graphile Worker Extensions

This crate provides Extensions struct and utils for the [Graphile Worker](docs.rs/archimedes) job scheduler
Loading

0 comments on commit 00bfd36

Please sign in to comment.