Skip to content

Commit 362492f

Browse files
Merge pull request #131 from jcrossley3/single-crate
Refactor runtime crates into feature-guarded modules
2 parents 303ed92 + 4979c44 commit 362492f

File tree

31 files changed

+2266
-28
lines changed

31 files changed

+2266
-28
lines changed

.github/workflows/rust_tests.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ jobs:
6060
with:
6161
command: build
6262
toolchain: ${{ matrix.toolchain }}
63-
args: --target ${{ matrix.target }} --workspace
63+
args: --target ${{ matrix.target }} --workspace --all-features
6464
- uses: actions-rs/cargo@v1
6565
name: "Test"
6666
if: matrix.target == 'x86_64-unknown-linux-gnu'
6767
with:
6868
command: test
6969
toolchain: ${{ matrix.toolchain }}
70-
args: --target ${{ matrix.target }} --workspace
70+
args: --target ${{ matrix.target }} --workspace --all-features
7171

7272
# If musl, compile and test all
7373
- uses: actions-rs/cargo@v1
@@ -76,7 +76,7 @@ jobs:
7676
with:
7777
command: build
7878
toolchain: ${{ matrix.toolchain }}
79-
args: --target ${{ matrix.target }} --workspace
79+
args: --target ${{ matrix.target }} --workspace --all-features
8080
env:
8181
CC: musl-gcc
8282
CXX: g++
@@ -86,19 +86,18 @@ jobs:
8686
with:
8787
command: test
8888
toolchain: ${{ matrix.toolchain }}
89-
args: --target ${{ matrix.target }} --workspace
89+
args: --target ${{ matrix.target }} --workspace --all-features
9090
env:
9191
CC: musl-gcc
9292
CXX: g++
9393

94-
# If wasm, then we test only the main module and cloudevents-sdk-reqwest
9594
- uses: actions-rs/cargo@v1
9695
name: "Build"
9796
if: matrix.target == 'wasm32-unknown-unknown'
9897
with:
9998
command: build
10099
toolchain: ${{ matrix.toolchain }}
101-
args: --target wasm32-unknown-unknown --package cloudevents-sdk --package cloudevents-sdk-reqwest
100+
args: --target wasm32-unknown-unknown --features cloudevents-reqwest
102101

103102
# Build examples
104103
- uses: actions-rs/cargo@v1

Cargo.toml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ categories = ["web-programming", "encoding", "data-structures"]
1616
[lib]
1717
name = "cloudevents"
1818

19+
[features]
20+
cloudevents-actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
21+
cloudevents-reqwest = ["reqwest", "async-trait", "lazy_static", "bytes"]
22+
cloudevents-rdkafka = ["rdkafka", "lazy_static", "bytes"]
23+
cloudevents-warp = ["warp", "lazy_static", "bytes", "http", "hyper"]
24+
1925
[dependencies]
2026
serde = { version = "^1.0", features = ["derive"] }
2127
serde_json = "^1.0"
@@ -26,6 +32,18 @@ url = { version = "^2.1", features = ["serde"] }
2632
snafu = "^0.6"
2733
bitflags = "^1.2"
2834

35+
# runtime optional deps
36+
actix-web = { version = "^3", default-features = false, optional = true }
37+
reqwest = { version = "^0.11", default-features = false, features = ["rustls-tls"], optional = true }
38+
rdkafka = { version = "^0.25", features = ["cmake-build"], optional = true }
39+
warp = { version = "^0.3", optional = true }
40+
async-trait = { version = "^0.1.33", optional = true }
41+
lazy_static = { version = "1.4.0", optional = true }
42+
bytes = { version = "^1.0", optional = true }
43+
futures = { version = "^0.3", optional = true }
44+
http = { version = "0.2", optional = true }
45+
hyper = { version = "^0.14", optional = true }
46+
2947
[target."cfg(not(target_arch = \"wasm32\"))".dependencies]
3048
hostname = "^0.3"
3149
uuid = { version = "^0.8", features = ["v4"] }
@@ -40,13 +58,22 @@ claim = "0.3.1"
4058
version-sync = "^0.9"
4159
serde_yaml = "0.8"
4260

61+
# runtime dev-deps
62+
actix-rt = { version = "^1" }
63+
url = { version = "^2.1", features = ["serde"] }
64+
serde_json = { version = "^1.0" }
65+
chrono = { version = "^0.4", features = ["serde"] }
66+
mockito = "0.25.1"
67+
tokio = { version = "^1.0", features = ["full"] }
68+
mime = "0.3"
69+
4370
[workspace]
4471
members = [
4572
".",
4673
"cloudevents-sdk-actix-web",
4774
"cloudevents-sdk-reqwest",
4875
"cloudevents-sdk-rdkafka",
49-
"cloudevents-sdk-warp"
76+
"cloudevents-sdk-warp",
5077
]
5178
exclude = [
5279
"example-projects/actix-web-example",

cloudevents-sdk-actix-web/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cloudevents-sdk = { version = "0.3.0", path = ".." }
1717
actix-web = { version = "^3", default-features = false }
1818
async-trait = "^0.1.33"
1919
lazy_static = "1.4.0"
20-
bytes = "^0.5"
20+
bytes = "^1.0"
2121
futures = "^0.3"
2222

2323
[dev-dependencies]

cloudevents-sdk-rdkafka/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ rdkafka = { version = "^0.25", features = ["cmake-build"] }
2222
url = { version = "^2.1" }
2323
serde_json = "^1.0"
2424
chrono = { version = "^0.4", features = ["serde"] }
25-
futures = "0.3.5"
25+
futures = "^0.3"
2626
version-sync = "^0.9"

example-projects/actix-web-example/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ authors = ["Francesco Guardiani <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
cloudevents-sdk = { path = "../.." }
9-
cloudevents-sdk-actix-web = { path = "../../cloudevents-sdk-actix-web" }
8+
cloudevents-sdk = { path = "../..", features = ["cloudevents-actix"] }
109
actix-web = "^3"
1110
actix-cors = "^0.5"
1211
lazy_static = "1.4.0"

example-projects/actix-web-example/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use actix_web::{get, post, web, App, HttpRequest, HttpResponse, HttpServer};
2+
use cloudevents::actix::{HttpRequestExt, HttpResponseBuilderExt};
23
use cloudevents::{EventBuilder, EventBuilderV10};
3-
use cloudevents_sdk_actix_web::{HttpResponseBuilderExt, HttpRequestExt};
44
use serde_json::json;
55

66
#[post("/")]

example-projects/rdkafka-example/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ edition = "2018"
88

99
[dependencies]
1010
async-trait = "^0.1.33"
11-
cloudevents-sdk = { path = "../.." }
12-
cloudevents-sdk-rdkafka = { path = "../../cloudevents-sdk-rdkafka" }
11+
cloudevents-sdk = { path = "../..", features = ["cloudevents-rdkafka"] }
1312
lazy_static = "1.4.0"
1413
bytes = "^1.0"
1514
url = { version = "^2.1", features = ["serde"] }

example-projects/rdkafka-example/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use futures::StreamExt;
33
use serde_json::json;
44

55
use cloudevents::{EventBuilder, EventBuilderV10};
6-
use cloudevents_sdk_rdkafka::{FutureRecordExt, MessageExt, MessageRecord};
6+
use cloudevents::rdkafka::{FutureRecordExt, MessageExt, MessageRecord};
77

88
use rdkafka::config::{ClientConfig, RDKafkaLogLevel};
99
use rdkafka::consumer::stream_consumer::StreamConsumer;

example-projects/reqwest-wasm-example/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ crate-type = ["cdylib"]
1111

1212
[dependencies]
1313
reqwest = "^0.11"
14-
cloudevents-sdk = { path = "../.." }
15-
cloudevents-sdk-reqwest = { path = "../../cloudevents-sdk-reqwest" }
14+
cloudevents-sdk = { path = "../..", features = ["cloudevents-reqwest"] }
1615
url = { version = "^2.1" }
1716
web-sys = { version = "0.3.39", features = ["Window", "Location"] }
1817
wasm-bindgen-futures = "0.4.12"

example-projects/reqwest-wasm-example/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use cloudevents::reqwest::RequestBuilderExt;
12
use cloudevents::{EventBuilder, EventBuilderV10};
2-
use cloudevents_sdk_reqwest::RequestBuilderExt;
33
use wasm_bindgen::prelude::*;
44

55
#[wasm_bindgen]

0 commit comments

Comments
 (0)