Skip to content

Commit

Permalink
Merge pull request #2726 from fermyon/integrate-outbound-redis
Browse files Browse the repository at this point in the history
[Factors] Integrate outbound Redis
  • Loading branch information
lann authored Aug 19, 2024
2 parents c6fb174 + 1b25410 commit 666de56
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

12 changes: 11 additions & 1 deletion crates/factor-outbound-redis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ use spin_factors::{
anyhow, ConfigureAppContext, Factor, InstanceBuilders, PrepareContext, RuntimeFactors,
SelfInstanceBuilder,
};
pub struct OutboundRedisFactor;

/// The [`Factor`] for `fermyon:spin/outbound-redis`.
pub struct OutboundRedisFactor {
_priv: (),
}

impl OutboundRedisFactor {
pub fn new() -> Self {
Self { _priv: () }
}
}

impl Factor for OutboundRedisFactor {
type RuntimeConfig = ();
Expand Down
2 changes: 1 addition & 1 deletion crates/factor-outbound-redis/tests/factor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn no_outbound_hosts_fails() -> anyhow::Result<()> {
let factors = TestFactors {
variables: VariablesFactor::default(),
networking: OutboundNetworkingFactor,
redis: OutboundRedisFactor,
redis: OutboundRedisFactor::new(),
};
let env = TestEnvironment::new(factors).extend_manifest(toml! {
spin_manifest_version = 2
Expand Down
1 change: 1 addition & 0 deletions crates/runtime-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spin-factor-key-value-redis = { path = "../factor-key-value-redis" }
spin-factor-key-value-azure = { path = "../factor-key-value-azure" }
spin-factor-outbound-http = { path = "../factor-outbound-http" }
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
spin-factor-outbound-redis = { path = "../factor-outbound-redis" }
spin-factor-sqlite = { path = "../factor-sqlite" }
spin-factor-variables = { path = "../factor-variables" }
spin-factor-wasi = { path = "../factor-wasi" }
Expand Down
17 changes: 14 additions & 3 deletions crates/runtime-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use spin_factor_key_value::{DefaultLabelResolver as _, KeyValueFactor};
use spin_factor_outbound_http::OutboundHttpFactor;
use spin_factor_outbound_networking::runtime_config::spin::SpinTlsRuntimeConfig;
use spin_factor_outbound_networking::OutboundNetworkingFactor;
use spin_factor_outbound_redis::OutboundRedisFactor;
use spin_factor_sqlite::runtime_config::spin as sqlite;
use spin_factor_variables::{spin_cli as variables, VariablesFactor};
use spin_factor_sqlite::SqliteFactor;
use spin_factor_variables::{spin_cli as variables, VariablesFactor};
use spin_factor_wasi::WasiFactor;
use spin_factors::{
runtime_config::toml::TomlKeyTracker, FactorRuntimeConfigSource, RuntimeConfigSourceFinalizer,
Expand Down Expand Up @@ -148,8 +149,18 @@ impl FactorRuntimeConfigSource<OutboundNetworkingFactor> for TomlRuntimeConfigSo
}

impl FactorRuntimeConfigSource<VariablesFactor> for TomlRuntimeConfigSource<'_> {
fn get_runtime_config(&mut self) -> anyhow::Result<Option<<VariablesFactor as spin_factors::Factor>::RuntimeConfig>> {
Ok(Some(variables::runtime_config_from_toml(self.table.as_ref())?))
fn get_runtime_config(
&mut self,
) -> anyhow::Result<Option<<VariablesFactor as spin_factors::Factor>::RuntimeConfig>> {
Ok(Some(variables::runtime_config_from_toml(
self.table.as_ref(),
)?))
}
}

impl FactorRuntimeConfigSource<OutboundRedisFactor> for TomlRuntimeConfigSource<'_> {
fn get_runtime_config(&mut self) -> anyhow::Result<Option<()>> {
Ok(None)
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/trigger2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spin-factor-variables = { path = "../factor-variables" }
spin-factor-wasi = { path = "../factor-wasi" }
spin-factor-key-value = { path = "../factor-key-value" }
spin-factor-sqlite = { path = "../factor-sqlite" }
spin-factor-outbound-redis = { path = "../factor-outbound-redis" }
spin-factors = { path = "../factors" }
spin-factors-executor = { path = "../factors-executor" }
spin-telemetry = { path = "../telemetry" }
Expand Down
3 changes: 3 additions & 0 deletions crates/trigger2/src/factors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;
use spin_factor_key_value::KeyValueFactor;
use spin_factor_outbound_http::OutboundHttpFactor;
use spin_factor_outbound_networking::OutboundNetworkingFactor;
use spin_factor_outbound_redis::OutboundRedisFactor;
use spin_factor_sqlite::SqliteFactor;
use spin_factor_variables::VariablesFactor;
use spin_factor_wasi::{spin::SpinFilesMounter, WasiFactor};
Expand All @@ -17,6 +18,7 @@ pub struct TriggerFactors {
pub outbound_networking: OutboundNetworkingFactor,
pub outbound_http: OutboundHttpFactor,
pub sqlite: SqliteFactor,
pub redis: OutboundRedisFactor,
}

impl TriggerFactors {
Expand All @@ -34,6 +36,7 @@ impl TriggerFactors {
outbound_networking: OutboundNetworkingFactor,
outbound_http: OutboundHttpFactor,
sqlite: SqliteFactor::new(default_sqlite_label_resolver),
redis: OutboundRedisFactor::new(),
}
}
}
Expand Down

0 comments on commit 666de56

Please sign in to comment.