Skip to content

Commit d05a2d3

Browse files
committed
feat(hydro_test): add Kafka example with producer/consumer module
- Add hydro_test/src/kafka/mod.rs with kafka_producer, kafka_consumer, dest_kafka, and setup_topic helpers following the SQS PR #2746 pattern - Complete hydro_test/examples/kafka.rs: leader produces 1M financial transactions, consumer cluster computes per-account balances - Add 'kafka' feature flag gating rdkafka and futures-util as optional deps - Add llvm-tools component to rust-toolchain.toml for rust-lld
1 parent c1619d0 commit d05a2d3

11 files changed

Lines changed: 634 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
- if: matrix.rust_release == 'latest-stable' && matrix.os == 'ubuntu-latest'
6565
uses: ./.github/actions/use-sccache
6666

67+
- name: Install libcurl dev (needed by rdkafka-sys)
68+
if: runner.os == 'Linux'
69+
run: sudo apt-get update -qq && sudo apt-get install -y -qq libcurl4-openssl-dev > /dev/null
70+
6771
- run: cargo clippy --all-targets -- -D warnings
6872
- run: cargo clippy --all-targets --no-default-features -- -D warnings
6973
- run: cargo clippy --all-targets --all-features -- -D warnings

.github/workflows/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
- name: Install nightly Rust channel
4141
run: rustup toolchain add nightly
4242

43+
- name: Install libcurl dev (needed by rdkafka-sys)
44+
run: sudo apt-get update -qq && sudo apt-get install -y -qq libcurl4-openssl-dev > /dev/null
45+
4346
- env:
4447
RUSTDOCFLAGS: --cfg docsrs -Dwarnings
4548
run: cargo +nightly doc --no-deps --all-features

Cargo.lock

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_docs.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
set -e
22

3+
sudo apt-get update -qq && sudo apt-get install -y -qq libcurl4-openssl-dev > /dev/null
4+
35
echo "========================================="
46
echo "Step 1/7: Downloading LLVM..."
57
echo "========================================="

hydro_deploy/core/src/aws.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ pub struct NetworkResources {
4747
security_group: String,
4848
}
4949

50+
impl NetworkResources {
51+
pub fn new(vpc: String, subnet: String, security_group: String) -> Self {
52+
Self {
53+
vpc,
54+
subnet,
55+
security_group,
56+
}
57+
}
58+
}
59+
5060
#[derive(Debug)]
5161
pub struct AwsNetwork {
5262
pub region: String,
@@ -910,6 +920,10 @@ echo -e "{cwa_config_esc}" > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwa
910920
"associate_public_ip_address": true,
911921
"iam_instance_profile": iam_instance_profile_ref, // May be `None`.
912922
"user_data": user_data_script, // May be `None`.
923+
"metadata_options": {
924+
"http_tokens": "required",
925+
"http_endpoint": "enabled"
926+
},
913927
"tags": {
914928
"Name": instance_name
915929
}

hydro_deploy/core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub mod azure;
2929
pub use azure::AzureHost;
3030

3131
pub mod aws;
32-
pub use aws::{AwsEc2Host, AwsNetwork};
32+
pub use aws::{AwsEc2Host, AwsNetwork, NetworkResources};
3333

3434
pub mod rust_crate;
3535
pub use rust_crate::RustCrate;

hydro_test/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ docker = ["hydro_lang/docker_deploy"]
1212
ecs = ["hydro_lang/ecs_deploy"]
1313
maelstrom = ["hydro_lang/maelstrom"]
1414
stageleft_macro_entrypoint = ["hydro_lang/stageleft_macro_entrypoint"]
15+
kafka = ["dep:rdkafka", "dep:futures-util"]
16+
17+
[[example]]
18+
name = "kafka"
19+
required-features = ["kafka"]
1520

1621
[dependencies]
1722
hydro_lang = { path = "../hydro_lang", version = "^0.15.0" }
@@ -33,6 +38,8 @@ bytes = "1.1.0"
3338
# https://github.com/GitoxideLabs/cargo-smart-release/issues/36
3439
example_test = { path = "../example_test", version = "^0.0.0", optional = true }
3540
hydro_build_utils = { path = "../hydro_build_utils", version = "^0.0.1", optional = true }
41+
rdkafka = { version = "0.39.0", optional = true, features = ["cmake-build", "ssl-vendored"] }
42+
futures-util = { version = "0.3.0", default-features = false, features = ["alloc"], optional = true }
3643

3744
[build-dependencies]
3845
stageleft_tool.workspace = true

0 commit comments

Comments
 (0)