Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ runs:
steps:
- name: Build Documentation
shell: bash
run: cargo doc --no-deps -p launchdarkly-server-sdk
run: cargo doc --no-deps --all-features -p launchdarkly-server-sdk
10 changes: 8 additions & 2 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI Workflow
description: 'Shared CI workflow.'

inputs:
feature-flags:
description: 'Cargo feature flags to pass to test and clippy commands'
required: false
default: ''

runs:
using: composite
steps:
Expand All @@ -10,8 +16,8 @@ runs:

- name: Run tests
shell: bash
run: cargo test -p launchdarkly-server-sdk
run: cargo test ${{ inputs.feature-flags }} -p launchdarkly-server-sdk

- name: Run clippy checks
shell: bash
run: cargo clippy -p launchdarkly-server-sdk -- -D warnings
run: cargo clippy ${{ inputs.feature-flags }} -p launchdarkly-server-sdk -- -D warnings
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ on:
jobs:
ci-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
- name: "default"
flags: ""
- name: "no-features"
flags: "--no-default-features"
- name: "hyper"
flags: "--no-default-features --features hyper"
- name: "hyper-rustls"
flags: "--no-default-features --features hyper-rustls"

name: CI (${{ matrix.features.name }})

steps:
- uses: actions/checkout@v4
Expand All @@ -28,6 +42,25 @@ jobs:
rustup component add rustfmt clippy

- uses: ./.github/actions/ci
with:
feature-flags: ${{ matrix.features.flags }}

contract-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Rust version
id: rust-version
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT

- name: Setup rust tooling
run: |
rustup override set ${{ steps.rust-version.outputs.target }}
rustup component add rustfmt clippy

- name: "Run contract tests with hyper_rustls"
uses: ./.github/actions/contract-tests
Expand All @@ -41,6 +74,23 @@ jobs:
tls_feature: "tls"
token: ${{ secrets.GITHUB_TOKEN }}

build-docs:
runs-on: ubuntu-latest
name: Build Documentation (all features)

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Rust version
id: rust-version
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT

- name: Setup rust tooling
run: |
rustup override set ${{ steps.rust-version.outputs.target }}

- uses: ./.github/actions/build-docs

musl-build:
Expand Down
4 changes: 2 additions & 2 deletions contract-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ license = "Apache-2.0"
actix = "0.13.0"
actix-web = "4.2.1"
env_logger = "0.10.0"
# eventsource-client = { version = "0.16.0", default-features = false }
eventsource-client = { git = "https://github.com/launchdarkly/rust-eventsource-client", branch = "feat/hyper-as-feature" }
eventsource-client = { git = "https://github.com/launchdarkly/rust-eventsource-client.git", branch = "mk/sdk-1879/use-transport-crate" }
launchdarkly-sdk-transport = { git = "https://github.com/launchdarkly/rust-sdk-transport.git", branch = "main" }
log = "0.4.14"
launchdarkly-server-sdk = { path = "../launchdarkly-server-sdk/", default-features = false, features = ["event-compression"]}
serde = { version = "1.0.132", features = ["derive"] }
Expand Down
10 changes: 6 additions & 4 deletions contract-tests/src/client_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ impl ClientEntity {
connector: HttpsConnector,
) -> Result<Self, BuildError> {
// Create fresh transports for this client to avoid shared connection pool issues
let transport =
launchdarkly_server_sdk::HyperTransport::new_with_connector(connector.clone());
let streaming_https_transport =
eventsource_client::HyperTransport::builder().build_with_connector(connector.clone());
let transport = launchdarkly_sdk_transport::HyperTransport::builder()
.build_with_connector(connector.clone())
.map_err(|e| BuildError::InvalidConfig(e.to_string()))?;
let streaming_https_transport = launchdarkly_sdk_transport::HyperTransport::builder()
.build_with_connector(connector.clone())
.map_err(|e| BuildError::InvalidConfig(e.to_string()))?;
let mut config_builder =
ConfigBuilder::new(&create_instance_params.configuration.credential);

Expand Down
13 changes: 4 additions & 9 deletions launchdarkly-server-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ features = ["event-compression"]
chrono = "0.4.19"
crossbeam-channel = "0.5.1"
data-encoding = "2.3.2"
# eventsource-client = { version = "0.16.0", default-features = false }
eventsource-client = { git = "https://github.com/launchdarkly/rust-eventsource-client", default-features = false, branch = "feat/hyper-as-feature" }
eventsource-client = { git = "https://github.com/launchdarkly/rust-eventsource-client.git", branch = "mk/sdk-1879/use-transport-crate" }
launchdarkly-sdk-transport = { git = "https://github.com/launchdarkly/rust-sdk-transport.git", branch = "main" }
futures = "0.3.12"
log = "0.4.14"
lru = { version = "0.16.3", default-features = false }
Expand All @@ -37,11 +37,6 @@ uuid = {version = "1.2.2", features = ["v4"] }
http = "1.0"
bytes = "1.11"
bitflags = "2.4"
hyper = { version = "1.0", features = ["client", "http1", "http2"], optional = true }
hyper-util = { version = "0.1", features = ["client-legacy", "http1", "http2", "tokio"], optional = true }
http-body-util = { version = "0.1", optional = true }
hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "http2", "native-tokio", "ring", "webpki-roots"], optional = true}
tower = { version = "0.4", optional = true }
rand = "0.9"
flate2 = { version = "1.0.35", optional = true }
aws-lc-rs = "1.14.1"
Expand All @@ -60,8 +55,8 @@ testing_logger = "0.1.1"

[features]
default = ["hyper-rustls"]
hyper = ["dep:hyper", "dep:hyper-util", "dep:http-body-util", "dep:tower", "eventsource-client/hyper"]
hyper-rustls = ["dep:hyper-rustls", "hyper", "eventsource-client/hyper-rustls"]
hyper = ["launchdarkly-sdk-transport/hyper", "eventsource-client/hyper"]
hyper-rustls = ["hyper", "launchdarkly-sdk-transport/hyper-rustls", "eventsource-client/hyper-rustls"]
event-compression = ["flate2"]

[[example]]
Expand Down
9 changes: 4 additions & 5 deletions launchdarkly-server-sdk/examples/custom_transport.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use bytes::Bytes;
use http::Request;
use launchdarkly_server_sdk::{
ConfigBuilder, EventProcessorBuilder, HttpTransport, ResponseFuture,
};
use launchdarkly_sdk_transport::{HttpTransport, ResponseFuture};
use launchdarkly_server_sdk::{ConfigBuilder, EventProcessorBuilder};
use std::time::Instant;

/// Example of a custom transport that wraps another transport and adds logging.
Expand All @@ -21,7 +20,7 @@ impl<T: HttpTransport> LoggingTransport<T> {
}

impl<T: HttpTransport> HttpTransport for LoggingTransport<T> {
fn request(&self, request: Request<Bytes>) -> ResponseFuture {
fn request(&self, request: Request<Option<Bytes>>) -> ResponseFuture {
let method = request.method().clone();
let uri = request.uri().clone();
let start = Instant::now();
Expand Down Expand Up @@ -65,7 +64,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}

// Create the base HTTPS transport
let base_transport = launchdarkly_server_sdk::HyperTransport::new_https();
let base_transport = launchdarkly_sdk_transport::HyperTransport::new_https()?;

// Wrap it with logging middleware
let logging_transport = LoggingTransport::new(base_transport);
Expand Down
2 changes: 1 addition & 1 deletion launchdarkly-server-sdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2722,7 +2722,7 @@ mod tests {
.daemon_mode(daemon_mode)
.data_source(MockDataSourceBuilder::new().data_source(updates))
.event_processor(
EventProcessorBuilder::<crate::HyperTransport>::new()
EventProcessorBuilder::<launchdarkly_sdk_transport::HyperTransport>::new()
.event_sender(Arc::new(event_sender)),
)
.build()
Expand Down
17 changes: 14 additions & 3 deletions launchdarkly-server-sdk/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::events::processor_builders::{
};
use crate::stores::store_builders::{DataStoreFactory, InMemoryDataStoreBuilder};
use crate::{ServiceEndpointsBuilder, StreamingDataSourceBuilder};
use eventsource_client as es;

use std::borrow::Borrow;

Expand Down Expand Up @@ -303,7 +302,13 @@ impl ConfigBuilder {
Some(builder) => Ok(builder),
#[cfg(feature = "hyper-rustls")]
None => {
let transport = es::HyperTransport::new_https();
let transport = launchdarkly_sdk_transport::HyperTransport::new_https()
.map_err(|e| {
BuildError::InvalidConfig(format!(
"failed to create default transport: {}",
e
))
})?;
let mut builder = StreamingDataSourceBuilder::new();
builder.transport(transport);
Ok(Box::new(builder))
Expand All @@ -325,7 +330,13 @@ impl ConfigBuilder {
Some(builder) => Ok(builder),
#[cfg(feature = "hyper-rustls")]
None => {
let transport = crate::HyperTransport::new_https();
let transport = launchdarkly_sdk_transport::HyperTransport::new_https()
.map_err(|e| {
BuildError::InvalidConfig(format!(
"failed to create default transport: {}",
e
))
})?;
let mut builder = EventProcessorBuilder::new();
builder.transport(transport);
Ok(Box::new(builder))
Expand Down
9 changes: 5 additions & 4 deletions launchdarkly-server-sdk/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct StreamingDataSource {

impl StreamingDataSource {
#[allow(clippy::result_large_err)]
pub fn new<T: es::HttpTransport>(
pub fn new<T: launchdarkly_sdk_transport::HttpTransport>(
base_url: &str,
sdk_key: &str,
initial_reconnect_delay: Duration,
Expand Down Expand Up @@ -375,7 +375,6 @@ mod tests {
use super::{DataSource, PollingDataSource, StreamingDataSource};
use crate::feature_requester_builders::HttpFeatureRequesterBuilder;
use crate::{stores::store::InMemoryDataStore, LAUNCHDARKLY_TAGS_HEADER};
use eventsource_client as es;

#[test_case(Some("application-id/abc:application-sha/xyz".into()), "application-id/abc:application-sha/xyz")]
#[test_case(None, Matcher::Missing)]
Expand All @@ -402,7 +401,8 @@ mod tests {
"sdk-key",
Duration::from_secs(0),
&tag,
es::HyperTransport::new(),
launchdarkly_sdk_transport::HyperTransport::new()
.expect("Failed to create streaming data source"),
)
.unwrap();

Expand Down Expand Up @@ -453,7 +453,8 @@ mod tests {
let (shutdown_tx, _) = broadcast::channel::<()>(1);
let initialized = Arc::new(AtomicBool::new(false));

let transport = crate::HyperTransport::new();
let transport = launchdarkly_sdk_transport::HyperTransport::new()
.expect("Failed to create transport for polling data source");
let hyper_builder = HttpFeatureRequesterBuilder::new(&server.url(), "sdk-key", transport);

let polling = PollingDataSource::new(
Expand Down
Loading
Loading