Skip to content

Commit

Permalink
Support both openssl and rustls. Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
rustworthy committed Apr 21, 2024
1 parent 5a17498 commit 13eaace
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
- name: Run tests
env:
FAKTORY_URL_SECURE: tcp://localhost:17419
run: cargo test --locked --features openssl,rustls --test tls
run: cargo test --locked --features native_tls,rustls --test tls
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ exclude = [".github", "docker", ".gitignore", "Makefile"]

[features]
default = []
tls = ["dep:pin-project"]
openssl = ["tls", "dep:tokio-native-tls"]
rustls = ["tls", "dep:tokio-rustls"]
native_tls = ["dep:pin-project", "dep:tokio-native-tls"]
rustls = ["dep:pin-project", "dep:tokio-rustls"]
binaries = ["dep:clap", "tokio/macros"]
ent = []

Expand Down Expand Up @@ -56,7 +55,7 @@ x509-parser = "0.15.1"

# to make -Zminimal-versions work
[target.'cfg(any())'.dependencies]
openssl-crate = { package = "openssl", version = "0.10.60", optional = true }
openssl = { version = "0.10.60", optional = true }
native-tls = { version = "0.2.4", optional = true }
num-bigint = "0.4.2"
oid-registry = "0.6.1"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test/e2e:
.PHONY: test/e2e/tls
test/e2e/tls:
FAKTORY_URL_SECURE=tcp://${FAKTORY_HOST}:${FAKTORY_PORT_SECURE} \
cargo test --locked --features openssl,rustls --test tls
cargo test --locked --features native_tls,rustls --test tls

.PHONY: test/load
test/load:
Expand Down
5 changes: 3 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ pub enum Error {
Serialization(#[source] serde_json::Error),

/// Indicates an error in the underlying TLS stream.
#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
#[cfg(any(feature = "native_tls", feature = "rustls"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "native_tls", feature = "rustls"))))]
#[error("underlying tls stream")]
TlsStream(#[source] tokio_native_tls::native_tls::Error),
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ pub mod ent {
};
}

#[cfg(feature = "tls")]
#[cfg(any(feature = "native_tls", feature = "rustls"))]
mod tls;

#[cfg(feature = "tls")]
#[cfg(any(feature = "native_tls", feature = "rustls"))]
pub use tls::*;
8 changes: 4 additions & 4 deletions src/tls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#[cfg(feature = "openssl")]
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
/// Namespace for OpenSSL-powered [`TlsStream`](crate::openssl::TlsStream).
#[cfg(feature = "native_tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "native_tls")))]
/// Namespace for native TLS powered [`TlsStream`](crate::native_tls::TlsStream).
///
/// The underlying crate (`native-tls`) will use _SChannel_ on Windows,
/// _SecureTransport_ on OSX, and _OpenSSL_ on other platforms.
pub mod openssl;
pub mod native_tls;

#[cfg(feature = "rustls")]
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
Expand Down
2 changes: 1 addition & 1 deletion src/tls/openssl.rs → src/tls/native_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use tokio_native_tls::{native_tls::TlsConnector, TlsConnector as AsyncTlsConnect
/// ```no_run
/// # tokio_test::block_on(async {
/// use faktory::Client;
/// use faktory::openssl::TlsStream;
/// use faktory::native_tls::TlsStream;
/// let tls = TlsStream::connect(None).await.unwrap();
/// let cl = Client::connect_with(tls, None).await.unwrap();
/// # drop(cl);
Expand Down
6 changes: 3 additions & 3 deletions tests/tls/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "openssl")]
mod native;
#[cfg(feature = "native_tls")]
mod native_tls;

#[cfg(feature = "rustls")]
mod rust;
mod rustls;
2 changes: 1 addition & 1 deletion tests/tls/native.rs → tests/tls/native_tls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use faktory::openssl::TlsStream;
use faktory::native_tls::TlsStream;
use faktory::{Client, Job, WorkerBuilder};
use serde_json::Value;
use std::{env, sync};
Expand Down
File renamed without changes.

0 comments on commit 13eaace

Please sign in to comment.