Skip to content

Commit 7419d59

Browse files
authored
chore: Merge hyper-as-feature feature branch (#121)
1 parent e967d64 commit 7419d59

File tree

17 files changed

+511
-266
lines changed

17 files changed

+511
-266
lines changed

.github/actions/build-docs/action.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/actions/ci/action.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: CI Workflow
2-
description: 'Shared CI workflow.'
2+
description: "Shared CI workflow."
3+
4+
inputs:
5+
cargo-flags:
6+
description: "Flags to pass to cargo commands."
7+
required: false
8+
default: ""
39

410
runs:
511
using: composite
@@ -10,20 +16,24 @@ runs:
1016

1117
- name: Run tests
1218
shell: bash
13-
run: cargo test --all-features -p eventsource-client
19+
run: cargo test ${{ inputs.cargo-flags }} -p eventsource-client
20+
21+
- name: Run slower integration tests
22+
shell: bash
23+
run: cargo test ${{ inputs.cargo-flags }} -p eventsource-client --lib -- --ignored
1424

1525
- name: Run clippy checks
1626
shell: bash
17-
run: cargo clippy --all-features -p eventsource-client -- -D warnings
27+
run: cargo clippy ${{ inputs.cargo-flags }} -p eventsource-client -- -D warnings
1828

1929
- name: Build contract tests
2030
shell: bash
21-
run: make build-contract-tests
31+
run: CARGO_FLAGS="${{ inputs.cargo-flags }}" make build-contract-tests
2232

2333
- name: Start contract test service
2434
shell: bash
25-
run: make start-contract-test-service-bg
35+
run: CARGO_FLAGS="${{ inputs.cargo-flags }}" make start-contract-test-service-bg
2636

2737
- name: Run contract tests
2838
shell: bash
29-
run: make run-contract-tests
39+
run: CARGO_FLAGS="${{ inputs.cargo-flags }}" make run-contract-tests

.github/workflows/ci.yml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
name: Run CI
22
on:
33
push:
4-
branches: [main]
4+
branches:
5+
- "main"
6+
- "feat/**"
57
paths-ignore:
68
- "**.md" # Do not need to run CI for markdown changes.
79
pull_request:
8-
branches: [main]
10+
branches:
11+
- "main"
12+
- "feat/**"
913
paths-ignore:
1014
- "**.md"
1115

1216
jobs:
1317
ci-build:
1418
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
features:
23+
- name: "default"
24+
cargo-flags: ""
25+
- name: "hyper-rustls-native-roots"
26+
cargo-flags: "--no-default-features --features hyper-rustls-native-roots"
27+
- name: "hyper-rustls-webpki-roots"
28+
cargo-flags: "--no-default-features --features hyper-rustls-webpki-roots"
29+
- name: "native-tls"
30+
cargo-flags: "--no-default-features --features native-tls"
31+
32+
name: CI (${{ matrix.features.name }})
1533

1634
steps:
1735
- uses: actions/checkout@v4
1836

37+
- name: Get Rust version
38+
id: rust-version
39+
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT
40+
1941
- name: Get Rust version
2042
id: rust-version
2143
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT
@@ -26,4 +48,23 @@ jobs:
2648
rustup component add rustfmt clippy
2749
2850
- uses: ./.github/actions/ci
29-
- uses: ./.github/actions/build-docs
51+
with:
52+
cargo-flags: ${{ matrix.features.cargo-flags }}
53+
54+
build-docs:
55+
runs-on: ubuntu-latest
56+
name: Build Documentation (all features)
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
63+
- name: Setup rust tooling
64+
run: rustup override set nightly
65+
66+
- name: Install cargo-docs-rs
67+
run: cargo install cargo-docs-rs
68+
69+
- name: Build documentation
70+
run: cargo docs-rs -p eventsource-client

.github/workflows/manual-publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
rustup component add rustfmt clippy
2828
2929
- uses: ./.github/actions/ci
30-
- uses: ./.github/actions/build-docs
3130

3231
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
3332
name: "Get crates.io token"

.github/workflows/release-please.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: Run Release Please
33
on:
44
push:
55
branches:
6-
- main
6+
- "main"
7+
- "feat/**"
78

89
jobs:
910
release-package:
@@ -26,6 +27,11 @@ jobs:
2627
id: rust-version
2728
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT
2829

30+
- name: Get Rust version
31+
if: ${{ steps.release.outputs['eventsource-client--release_created'] == 'true' }}
32+
id: rust-version
33+
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT
34+
2935
- name: Setup rust tooling
3036
if: ${{ steps.release.outputs['eventsource-client--release_created'] == 'true' }}
3137
run: |
@@ -42,9 +48,6 @@ jobs:
4248
- uses: ./.github/actions/ci
4349
if: ${{ steps.release.outputs['eventsource-client--release_created'] == 'true' }}
4450

45-
- uses: ./.github/actions/build-docs
46-
if: ${{ steps.release.outputs['eventsource-client--release_created'] == 'true' }}
47-
4851
- uses: ./.github/actions/publish
4952
if: ${{ steps.release.outputs['eventsource-client--release_created'] == 'true' }}
5053
with:

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"eventsource-client": "0.16.2"
2+
"eventsource-client": "0.16.2"
33
}

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
TEMP_TEST_OUTPUT=/tmp/contract-test-service.log
2+
CARGO_FLAGS ?= ""
23

34
build-contract-tests:
4-
@cargo build
5+
@cargo build $(CARGO_FLAGS)
56

67
start-contract-test-service: build-contract-tests
78
@./target/debug/sse-test-api
89

910
start-contract-test-service-bg:
1011
@echo "Test service output will be captured in $(TEMP_TEST_OUTPUT)"
11-
@make start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 &
12+
@$(MAKE) start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 &
1213

1314
run-contract-tests:
14-
@curl -s https://raw.githubusercontent.com/launchdarkly/sse-contract-tests/v2.0.0/downloader/run.sh \
15+
@curl -s https://raw.githubusercontent.com/launchdarkly/sse-contract-tests/main/downloader/run.sh \
1516
| VERSION=v2 PARAMS="-url http://localhost:8080 -debug -stop-service-at-end $(SKIPFLAGS) $(TEST_HARNESS_PARAMS)" sh
1617

1718
contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests

contract-tests/Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@ eventsource-client = { path = "../eventsource-client" }
1111
serde_json = { version = "1.0.39"}
1212
actix = { version = "0.13.1"}
1313
actix-web = { version = "4"}
14-
reqwest = { version = "0.11.6", default-features = false, features = ["json", "rustls-tls"] }
14+
# reqwest is required for callback client (test harness communication)
15+
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
1516
env_logger = { version = "0.10.0" }
16-
hyper = { version = "0.14.19", features = ["client", "http1", "tcp"] }
1717
log = "0.4.6"
18+
http = "1.0"
19+
bytes = "1.5"
20+
21+
launchdarkly-sdk-transport = { version = "0.1.0" }
1822

1923
[[bin]]
2024
name = "sse-test-api"
25+
26+
[features]
27+
default = ["hyper"]
28+
hyper = ["eventsource-client/hyper", "launchdarkly-sdk-transport/hyper"]
29+
native-tls = ["hyper", "eventsource-client/native-tls"]
30+
hyper-rustls-native-roots = ["hyper", "eventsource-client/hyper-rustls-native-roots"]
31+
hyper-rustls-webpki-roots = ["hyper", "eventsource-client/hyper-rustls-webpki-roots"]

contract-tests/src/bin/sse-test-api/stream_entity.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{
77
};
88

99
use eventsource_client as es;
10+
use launchdarkly_sdk_transport::HyperTransport;
1011

1112
use crate::{Config, EventType};
1213

@@ -102,10 +103,6 @@ impl Inner {
102103
reconnect_options = reconnect_options.delay(Duration::from_millis(delay_ms));
103104
}
104105

105-
if let Some(read_timeout_ms) = config.read_timeout_ms {
106-
client_builder = client_builder.read_timeout(Duration::from_millis(read_timeout_ms));
107-
}
108-
109106
if let Some(last_event_id) = &config.last_event_id {
110107
client_builder = client_builder.last_event_id(last_event_id.clone());
111108
}
@@ -127,8 +124,34 @@ impl Inner {
127124
}
128125
}
129126

127+
// Build with HyperTransport
128+
let mut transport_builder = HyperTransport::builder();
129+
130+
if let Some(timeout_ms) = config.read_timeout_ms {
131+
transport_builder = transport_builder.read_timeout(Duration::from_millis(timeout_ms));
132+
}
133+
134+
#[cfg(any(
135+
feature = "hyper-rustls-native-roots",
136+
feature = "hyper-rustls-webpki-roots",
137+
feature = "native-tls"
138+
))]
139+
let transport = transport_builder
140+
.build_https()
141+
.map_err(|e| format!("Failed to build HTTPS transport: {e:?}"))?;
142+
#[cfg(not(any(
143+
feature = "hyper-rustls-native-roots",
144+
feature = "hyper-rustls-webpki-roots",
145+
feature = "native-tls"
146+
)))]
147+
let transport = transport_builder
148+
.build_http()
149+
.map_err(|e| format!("Failed to build HTTP transport: {e:?}"))?;
150+
130151
Ok(Box::new(
131-
client_builder.reconnect(reconnect_options.build()).build(),
152+
client_builder
153+
.reconnect(reconnect_options.build())
154+
.build_with_transport(transport),
132155
))
133156
}
134157
}

eventsource-client/Cargo.toml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ keywords = ["launchdarkly", "feature-flags", "feature-toggles", "eventsource", "
1111
exclude = ["CHANGELOG.md"]
1212

1313
[dependencies]
14+
bytes = "1.5"
1415
futures = "0.3.21"
15-
hyper = { version = "0.14.19", features = ["client", "http1", "tcp"] }
16-
hyper-rustls = { version = "0.24.1", optional = true }
16+
http = "1.0"
1717
log = "0.4.6"
1818
pin-project = "1.0.10"
1919
tokio = { version = "1.17.0", features = ["time"] }
20-
hyper-timeout = "0.4.1"
2120
rand = "0.8.5"
2221
base64 = "0.22.1"
2322

23+
launchdarkly-sdk-transport = { version = "0.1.0" }
24+
2425
[dev-dependencies]
2526
env_logger = "0.10.0"
2627
maplit = "1.0.1"
@@ -30,11 +31,13 @@ tokio = { version = "1.2.0", features = ["macros", "rt-multi-thread"] }
3031
test-case = "3.2.1"
3132
proptest = "1.0.0"
3233

33-
34-
[features]
35-
default = ["rustls"]
36-
rustls = ["hyper-rustls", "hyper-rustls/http2"]
37-
3834
[[example]]
3935
name = "tail"
40-
required-features = ["rustls"]
36+
required-features = ["hyper"]
37+
38+
[features]
39+
default = ["hyper"]
40+
hyper = ["launchdarkly-sdk-transport/hyper"]
41+
native-tls = ["hyper", "launchdarkly-sdk-transport/native-tls"]
42+
hyper-rustls-native-roots = ["hyper", "launchdarkly-sdk-transport/hyper-rustls-native-roots"]
43+
hyper-rustls-webpki-roots = ["hyper", "launchdarkly-sdk-transport/hyper-rustls-webpki-roots"]

0 commit comments

Comments
 (0)