Skip to content

Commit

Permalink
Merge pull request #175 from kate-goldenring/mqtt-trigger
Browse files Browse the repository at this point in the history
Add MQTT trigger and tests
  • Loading branch information
kate-goldenring authored Aug 26, 2024
2 parents 5a7986d + 488eecb commit d6946c2
Show file tree
Hide file tree
Showing 20 changed files with 1,165 additions and 18 deletions.
8 changes: 6 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ strip = "symbols"
panic = "abort"

[target.aarch64-unknown-linux-musl]
# see https://github.com/fermyon/spin/commit/07db218dccf2d02eb6c8c74d0b39dd2eb59cc4b4
rustflags = ["-Ctarget-feature=+fp16"]
# see https://github.com/fermyon/spin/pull/2307/files#diff-f6009bd0d260464389ace37ab2f89adae993e1fa4a47f779e4c9859937005ced
rustflags = ["-C", "target-feature=+fp16", "-C", "target-feature=+crt-static", "-C", "link-self-contained=yes"]

[target.x86_64-unknown-linux-musl]
# see https://github.com/fermyon/spin/pull/2307/files#diff-f6009bd0d260464389ace37ab2f89adae993e1fa4a47f779e4c9859937005ced
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-self-contained=yes"]
54 changes: 54 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion containerd-shim-spin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ spin-componentize = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v2.6.0", features = ["unsafe-aot-compilation"] }
spin-trigger-http = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-trigger-redis = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
trigger-mqtt = { git = "https://github.com/spinkube/spin-trigger-mqtt", tag = "v0.2.0" }
trigger-sqs = { git = "https://github.com/fermyon/spin-trigger-sqs", rev = "v0.7.0" }
trigger-command = { git = "https://github.com/fermyon/spin-trigger-command", tag = "v0.1.0" }
spin-manifest = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-loader = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-oci = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-oci = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-common = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-expressions = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-telemetry = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
Expand Down
15 changes: 13 additions & 2 deletions containerd-shim-spin/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use spin_trigger_http::HttpTrigger;
use spin_trigger_redis::RedisTrigger;
use tokio::runtime::Runtime;
use trigger_command::CommandTrigger;
use trigger_mqtt::MqttTrigger;
use trigger_sqs::SqsTrigger;
use url::Url;

Expand Down Expand Up @@ -280,8 +281,17 @@ impl SpinEngine {
guest_args: ctx.args().to_vec(),
})
}
MqttTrigger::TRIGGER_TYPE => {
let mqtt_trigger: MqttTrigger = self
.build_spin_trigger(working_dir.clone(), app.clone(), app_source.clone())
.await
.context("failed to build spin trigger")?;

info!(" >>> running spin trigger");
mqtt_trigger.run(trigger_mqtt::CliArgs { test: false })
}
_ => {
todo!("Only Http, Redis and SQS triggers are currently supported.")
todo!("Only Http, Redis, MQTT and SQS triggers are currently supported.")
}
};

Expand Down Expand Up @@ -542,9 +552,10 @@ fn trigger_command_for_resolved_app_source(resolved: &ResolvedAppSource) -> Resu
RedisTrigger::TRIGGER_TYPE
| HttpTrigger::TRIGGER_TYPE
| SqsTrigger::TRIGGER_TYPE
| MqttTrigger::TRIGGER_TYPE
| CommandTrigger::TRIGGER_TYPE => types.push(trigger_type),
_ => {
todo!("Only Http, Redis and SQS triggers are currently supported.")
todo!("Only Http, Redis, MQTT and SQS triggers are currently supported.")
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions cross/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ RUN apk-${MARCH} add zlib-dev zlib-static
# See https://github.com/fermyon/spin/issues/1786 for the upstream issue requiring this polyfill.
RUN --mount=type=bind,from=jorgeprendes420/gcc_vld1q_s8_x4_polyfill,source=/polyfill.sh,target=/polyfill.sh /polyfill.sh

## as per analysis done in https://github.com/fermyon/spin/pull/2287#issuecomment-1970145410 we need
## to disable the cmake config in cross-rs. Setting CROSS_SYSROOT=/ seems to have done the trick
ENV CROSS_SYSROOT=/

RUN apt-get -y update && \
apt-get install -y pkg-config protobuf-compiler
2 changes: 2 additions & 0 deletions images/spin-mqtt-message-logger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.spin/
Loading

0 comments on commit d6946c2

Please sign in to comment.