diff --git a/Cargo.lock b/Cargo.lock index a6a6e775..82adf89b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "faktory" -version = "0.12.3" +version = "0.12.4" dependencies = [ "async-trait", "bufstream", diff --git a/Cargo.toml b/Cargo.toml index 5bd7922c..5e21318e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "faktory" -version = "0.12.3" +version = "0.12.4" authors = ["Jon Gjengset "] edition = "2021" license = "MIT OR Apache-2.0" @@ -63,3 +63,7 @@ required-features = ["binaries"] name = "async_loadtest" path = "src/bin/async_loadtest.rs" required-features = ["binaries"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] diff --git a/src/error.rs b/src/error.rs index 38e14ec8..89de50ff 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,9 +1,9 @@ //! Enumerates all errors that this crate may return. //! -//! [`Error`] is the top level error enum. +//! [`enum@Error`] is the top level error enum. //! Most consumers should only need to interact with this type. //! This is also where more generic errors such as I/O errors are placed, -//! whereas the more specific errors ([`Connection`] and [`Protocol`]) are +//! whereas the more specific errors ([`Connect`] and [`Protocol`]) are //! related to logic. //! //! [`Connect`] describes errors specific to the connection logic, for example @@ -44,6 +44,7 @@ pub enum Error { /// Indicates an error in the underlying TLS stream. #[cfg(feature = "tls")] + #[cfg_attr(docsrs, doc(cfg(feature = "tls")))] #[error("underlying tls stream")] TlsStream(#[source] native_tls::Error), } @@ -95,6 +96,7 @@ pub enum Protocol { /// The server reported a unique constraint violation. #[cfg(feature = "ent")] + #[cfg_attr(docsrs, doc(cfg(feature = "ent")))] #[error("server reported unique constraint violation: {msg}")] UniqueConstraintViolation { /// The error message given by the server. diff --git a/src/lib.rs b/src/lib.rs index eadae5ae..704548ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,6 +55,7 @@ //! } //! ``` #![deny(missing_docs)] +#![cfg_attr(docsrs, feature(doc_cfg))] #![warn(rust_2018_idioms)] #[macro_use] @@ -67,8 +68,10 @@ mod producer; mod proto; #[cfg(feature = "tls")] +#[cfg_attr(docsrs, doc(cfg(feature = "tls")))] mod tls; #[cfg(feature = "tls")] +#[cfg_attr(docsrs, doc(cfg(feature = "tls")))] pub use tls::TlsStream; pub use crate::consumer::{Consumer, ConsumerBuilder}; diff --git a/src/proto/mod.rs b/src/proto/mod.rs index d90ff579..7759e39c 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -16,9 +16,6 @@ pub use self::single::{ QueueControl, RawResponse, }; -// responses that users can see -pub use self::single::Hi; - pub(crate) fn get_env_url() -> String { use std::env; let var = env::var("FAKTORY_PROVIDER").unwrap_or_else(|_| "FAKTORY_URL".to_string()); diff --git a/src/proto/single/mod.rs b/src/proto/single/mod.rs index a02df87b..86657b1b 100644 --- a/src/proto/single/mod.rs +++ b/src/proto/single/mod.rs @@ -8,6 +8,7 @@ mod resp; mod utils; #[cfg(feature = "ent")] +#[cfg_attr(docsrs, doc(cfg(feature = "ent")))] mod ent; use crate::error::Error; diff --git a/tests/real/enterprise.rs b/tests/real/enterprise.rs index b12ed85f..bfe48f42 100644 --- a/tests/real/enterprise.rs +++ b/tests/real/enterprise.rs @@ -316,15 +316,14 @@ fn ent_unique_job_until_start() { #[test] fn ent_unique_job_bypass_unique_lock() { use faktory::error; - use serde_json::Value; skip_if_not_enterprise!(); let url = learn_faktory_url(); let mut producer = Producer::connect(Some(&url)).unwrap(); - + let queue_name = "ent_unique_job_bypass_unique_lock"; let job1 = Job::builder("order") - .queue("ent_unique_job_bypass_unique_lock") + .queue(queue_name) .unique_for(60) .build(); @@ -332,7 +331,7 @@ fn ent_unique_job_bypass_unique_lock() { // the uniqueness lock will be bypassed on the server. This special case is mentioned in the docs: // https://github.com/contribsys/faktory/wiki/Ent-Unique-Jobs#bypassing-uniqueness let job2 = Job::builder("order") // same jobtype and args (args are just not set) - .queue("ent_unique_job_bypass_unique_lock") // same queue + .queue(queue_name) // same queue .build(); // NB: `unique_for` not set producer.enqueue(job1).unwrap(); @@ -340,7 +339,7 @@ fn ent_unique_job_bypass_unique_lock() { // This _is_ a 'duplicate'. let job3 = Job::builder("order") - .queue("ent_unique_job_bypass_unique_lock") + .queue(queue_name) .unique_for(60) // NB .build(); @@ -351,4 +350,14 @@ fn ent_unique_job_bypass_unique_lock() { } else { panic!("Expected protocol error.") } + + // let's consume three times from the queue to verify that the first two jobs + // have been enqueued for real, while the last one has not. + let mut c = ConsumerBuilder::default(); + c.register("order", |j| -> io::Result<_> { Ok(eprintln!("{:?}", j)) }); + let mut c = c.connect(Some(&url)).unwrap(); + + assert!(c.run_one(0, &[queue_name]).unwrap()); + assert!(c.run_one(0, &[queue_name]).unwrap()); + assert!(!c.run_one(0, &[queue_name]).unwrap()); // empty; }