From 91ed2c4ece1ad866cadcffc0184adc0e2c93dec6 Mon Sep 17 00:00:00 2001 From: leonardpahlke Date: Fri, 17 Nov 2023 16:54:41 +0100 Subject: [PATCH] add sqs spin trigger Signed-off-by: leonardpahlke --- containerd-shim-spin/Cargo.toml | 1 + containerd-shim-spin/src/engine.rs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/containerd-shim-spin/Cargo.toml b/containerd-shim-spin/Cargo.toml index ab1454a..23f3d1f 100644 --- a/containerd-shim-spin/Cargo.toml +++ b/containerd-shim-spin/Cargo.toml @@ -18,6 +18,7 @@ spin-core = { git = "https://github.com/fermyon/spin", tag = "v2.0.1" } spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v2.0.1" } spin-trigger-http = { git = "https://github.com/fermyon/spin", tag = "v2.0.1" } spin-redis-engine = { git = "https://github.com/fermyon/spin", tag = "v2.0.1" } +trigger-sqs = { git = "https://github.com/fermyon/spin-trigger-sqs", tag = "canary" } spin-manifest = { git = "https://github.com/fermyon/spin", tag = "v2.0.1" } spin-loader = { git = "https://github.com/fermyon/spin", tag = "v2.0.1" } spin-oci = { git = "https://github.com/fermyon/spin", tag = "v2.0.1" } diff --git a/containerd-shim-spin/src/engine.rs b/containerd-shim-spin/src/engine.rs index faea270..2ea04d9 100644 --- a/containerd-shim-spin/src/engine.rs +++ b/containerd-shim-spin/src/engine.rs @@ -7,6 +7,7 @@ use spin_loader::cache::Cache; use spin_loader::FilesMountStrategy; use spin_manifest::schema::v2::AppManifest; use spin_redis_engine::RedisTrigger; +use trigger-sqs::SqsTrigger; use spin_trigger::TriggerHooks; use spin_trigger::{loader, RuntimeConfig, TriggerExecutor, TriggerExecutorBuilder}; use spin_trigger_http::HttpTrigger; @@ -172,8 +173,17 @@ impl SpinEngine { info!(" >>> running spin trigger"); redis_trigger.run(spin_trigger::cli::NoArgs) } + SqsTrigger::TRIGGER_TYPE => { + let sqs_trigger: SqsTrigger = self + .build_spin_trigger(working_dir, app) + .await + .context("failed to build spin trigger")?; + + info!(" >>> running spin trigger"); + sqs_trigger.run(spin_trigger::cli::NoArgs) + } _ => { - todo!("Only Http and Redis triggers are currently supported.") + todo!("Only Http, Redis and SQS triggers are currently supported.") } }; info!(" >>> notifying main thread we are about to start"); @@ -297,9 +307,9 @@ fn trigger_command_for_resolved_app_source(resolved: &ResolvedAppSource) -> Resu let trigger_type = resolved.trigger_type()?; match trigger_type { - RedisTrigger::TRIGGER_TYPE | HttpTrigger::TRIGGER_TYPE => Ok(trigger_type.to_owned()), + RedisTrigger::TRIGGER_TYPE | HttpTrigger::TRIGGER_TYPE | SqsTrigger::TRIGGER_TYPE => Ok(trigger_type.to_owned()), _ => { - todo!("Only Http and Redis triggers are currently supported.") + todo!("Only Http, Redis and SQS triggers are currently supported.") } } }