Skip to content

Commit

Permalink
add redis feature
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Apr 21, 2024
1 parent 354e739 commit 1410c4f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
2 changes: 1 addition & 1 deletion kitsune-job-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = false
eula = false

[dependencies]
athena = { path = "../lib/athena" }
athena = { path = "../lib/athena", features = ["redis"] }
clap = { version = "4.5.4", features = ["derive", "wrap_help"] }
color-eyre = "0.6.3"
just-retry = { path = "../lib/just-retry" }
Expand Down
2 changes: 1 addition & 1 deletion kitsune/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ license = false
eula = false

[dependencies]
athena = { path = "../lib/athena" }
athena = { path = "../lib/athena", features = ["redis"] }
argon2 = { version = "0.5.3", features = ["std"] }
askama = { version = "0.12.1", features = [
"with-axum",
Expand Down
37 changes: 27 additions & 10 deletions lib/athena/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ edition.workspace = true
version.workspace = true
license = "MIT OR Apache-2.0"

[[example]]
name = "basic_queue"
required-features = ["redis"]

[dependencies]
ahash = "0.8.11"
ahash = { version = "0.8.11", optional = true }
async-trait = "0.1.80"
either = { version = "1.11.0", default-features = false }
either = { version = "1.11.0", default-features = false, optional = true }
futures-util = { version = "0.3.30", default-features = false }
iso8601-timestamp = { version = "0.2.17", features = ["diesel-pg"] }
just-retry = { path = "../just-retry" }
multiplex-pool = { path = "../multiplex-pool" }
once_cell = "1.19.0"
rand = "0.8.5"
iso8601-timestamp = "0.2.17"
just-retry = { path = "../just-retry", optional = true }
multiplex-pool = { path = "../multiplex-pool", optional = true }
once_cell = { version = "1.19.0", optional = true }
rand = { version = "0.8.5", optional = true }
redis = { version = "0.25.3", default-features = false, features = [
"ahash",
"connection-manager",
"script",
"streams",
"tokio-comp",
] }
serde = { version = "1.0.198", features = ["derive"] }
simd-json = "0.13.10"
], optional = true }
serde = { version = "1.0.198", features = ["derive"], optional = true }
simd-json = { version = "0.13.10", optional = true }
smol_str = "0.2.1"
speedy-uuid = { path = "../speedy-uuid", features = ["redis", "serde"] }
thiserror = "1.0.59"
Expand All @@ -32,6 +36,19 @@ tokio-util = { version = "0.7.10", features = ["rt"] }
tracing = "0.1.40"
typed-builder = "0.18.2"

[features]
redis = [
"dep:ahash",
"dep:either",
"dep:just-retry",
"dep:multiplex-pool",
"dep:once_cell",
"dep:rand",
"dep:redis",
"dep:serde",
"dep:simd-json",
]

[dev-dependencies]
redis = { version = "0.25.3", features = ["connection-manager"] }
tracing-subscriber = "0.3.18"
Expand Down
2 changes: 2 additions & 0 deletions lib/athena/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ pub enum Error {
#[error(transparent)]
ContextRepository(BoxError),

#[cfg(feature = "redis")]
#[error(transparent)]
Redis(#[from] redis::RedisError),

#[cfg(feature = "redis")]
#[error(transparent)]
SimdJson(#[from] simd_json::Error),

Expand Down
16 changes: 11 additions & 5 deletions lib/athena/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "redis")]
#[macro_use]
extern crate tracing;

Expand All @@ -9,23 +10,28 @@ use speedy_uuid::Uuid;
use std::sync::Arc;
use typed_builder::TypedBuilder;

pub use self::{error::Error, redis::JobQueue as RedisJobQueue};
pub use self::error::Error;
pub use tokio_util::task::TaskTracker;

#[cfg(feature = "redis")]
pub use self::redis::JobQueue as RedisJobQueue;

mod error;
mod macros;
#[cfg(feature = "redis")]
mod redis;

#[derive(TypedBuilder)]
#[non_exhaustive]
pub struct JobDetails<C> {
#[builder(setter(into))]
context: C,
pub context: C,
#[builder(default)]

Check warning on line 29 in lib/athena/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

lib/athena/src/lib.rs#L29

Added line #L29 was not covered by tests
fail_count: u32,
pub fail_count: u32,
#[builder(default = Uuid::now_v7(), setter(into))]

Check warning on line 31 in lib/athena/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

lib/athena/src/lib.rs#L31

Added line #L31 was not covered by tests
job_id: Uuid,
pub job_id: Uuid,
#[builder(default, setter(into))]

Check warning on line 33 in lib/athena/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

lib/athena/src/lib.rs#L33

Added line #L33 was not covered by tests
run_at: Option<Timestamp>,
pub run_at: Option<Timestamp>,
}

#[async_trait]
Expand Down

0 comments on commit 1410c4f

Please sign in to comment.