Skip to content

Commit

Permalink
Merge pull request #1588 from itowlson/public-host-component-init-data
Browse files Browse the repository at this point in the history
Add constructor for HostComponentInitData
  • Loading branch information
itowlson authored Jun 18, 2023
2 parents 42a9213 + 04b5fa8 commit 881a3be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/trigger/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ where
let working_dir = std::env::var(SPIN_WORKING_DIR).context(SPIN_WORKING_DIR)?;
let locked_url = std::env::var(SPIN_LOCKED_URL).context(SPIN_LOCKED_URL)?;

let init_data = crate::HostComponentInitData {
kv: self.key_values.clone(),
sqlite: self.sqlite_statements.clone(),
};
let init_data =
crate::HostComponentInitData::new(&*self.key_values, &*self.sqlite_statements);

let loader = TriggerLoader::new(working_dir, self.allow_transient_write);
let executor = self.build_executor(loader, locked_url, init_data).await?;
Expand Down
15 changes: 15 additions & 0 deletions crates/trigger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ pub struct HostComponentInitData {
sqlite: Vec<String>,
}

impl HostComponentInitData {
/// Create an instance of `HostComponentInitData`. `key_value_init_values`
/// will be added to the default key-value store; `sqlite_init_statements`
/// will be run against the default SQLite database.
pub fn new(
key_value_init_values: impl Into<Vec<(String, String)>>,
sqlite_init_statements: impl Into<Vec<String>>,
) -> Self {
Self {
kv: key_value_init_values.into(),
sqlite: sqlite_init_statements.into(),
}
}
}

/// Execution context for a TriggerExecutor executing a particular App.
pub struct TriggerAppEngine<Executor: TriggerExecutor> {
/// Engine to be used with this executor.
Expand Down

0 comments on commit 881a3be

Please sign in to comment.