Skip to content

Commit

Permalink
fix(spin-redis-engine): Fix error during startup
Browse files Browse the repository at this point in the history
Fixes the following error:

$ spin build up --follow-all
<..>
Successfully ran the build command for the Spin components.
Error: Failed to configure Redis trigger

Caused by:
    metadata error: missing required "redis_address"
Error: exit status: 1

Refs: fermyon#763.

Signed-off-by: Konstantin Shabanov <[email protected]>
  • Loading branch information
etehtsea committed Oct 2, 2022
1 parent b4b2b1d commit 6741cb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions crates/redis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod spin;

use std::collections::HashMap;

use anyhow::{Context, Result};
use anyhow::Result;
use async_trait::async_trait;
use futures::StreamExt;
use redis::{Client, ConnectionLike};
Expand Down Expand Up @@ -40,6 +40,13 @@ pub struct RedisTriggerConfig {
pub executor: IgnoredAny,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
struct TriggerMetadata {
r#type: String,
address: String,
}

#[async_trait]
impl TriggerExecutor for RedisTrigger {
const TRIGGER_TYPE: &'static str = "redis";
Expand All @@ -50,8 +57,8 @@ impl TriggerExecutor for RedisTrigger {
fn new(engine: TriggerAppEngine<Self>) -> Result<Self> {
let address = engine
.app()
.require_metadata("redis_address")
.context("Failed to configure Redis trigger")?;
.require_metadata::<TriggerMetadata>("trigger")?
.address;

let channel_components = engine
.trigger_configs()
Expand Down
2 changes: 1 addition & 1 deletion crates/testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl TestConfig {
"trigger_config": self.http_trigger_config,
},
]);
let metadata = from_json!({"name": "test-app", "redis_address": "test-redis-host"});
let metadata = from_json!({"name": "test-app", "trigger": {"address": "test-redis-host", "type": "redis"}});
let variables = Default::default();
LockedApp {
spin_lock_version: spin_app::locked::FixedVersion,
Expand Down

0 comments on commit 6741cb5

Please sign in to comment.