Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Factors] Key-Value in Trigger2 #2715

Merged
merged 2 commits into from
Aug 16, 2024
Merged

[Factors] Key-Value in Trigger2 #2715

merged 2 commits into from
Aug 16, 2024

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented Aug 14, 2024

Builds on #2711 so marking as draft until that merges

This moves runtime config handling for Spin CLI to its own crate.

@rylev rylev requested a review from lann August 14, 2024 17:30
@rylev rylev marked this pull request as draft August 14, 2024 17:30
Comment on lines +93 to +127
const DEFAULT_SPIN_STORE_FILENAME: &str = "sqlite_key_value.db";

/// The key-value runtime configuration resolver used by the trigger.
///
/// Takes a base path for the local store.
pub fn key_value_resolver(local_store_base_path: PathBuf) -> key_value::RuntimeConfigResolver {
let mut key_value = key_value::RuntimeConfigResolver::new();

// Register the supported store types.
// Unwraps are safe because the store types are known to not overlap.
key_value
.register_store_type(spin_factor_key_value_spin::SpinKeyValueStore::new(
local_store_base_path,
))
.unwrap();
key_value
.register_store_type(spin_factor_key_value_redis::RedisKeyValueStore::new())
.unwrap();
key_value
.register_store_type(spin_factor_key_value_azure::AzureKeyValueStore::new())
.unwrap();

// Add handling of "default" store.
key_value.add_default_store(
"default",
key_value::StoreConfig {
type_: spin_factor_key_value_spin::SpinKeyValueStore::RUNTIME_CONFIG_TYPE.to_owned(),
config: toml::toml! {
path = DEFAULT_SPIN_STORE_FILENAME
},
},
);

key_value
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course it doesn't need to be done in this PR but we'll almost certainly break this out into an e.g. key_value module with the next factor added, yeah?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea most likely.

let mut key_value = key_value::RuntimeConfigResolver::new();

// Register the supported store types.
// Unwraps are safe because the store types are known to not overlap.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

micro-nit: avoid the "s" word...

Suggested change
// Unwraps are safe because the store types are known to not overlap.
// Unwraps are fine because the store types are known to not overlap.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll change this in the next PR to avoid having to run CI again.

Base automatically changed from runtime-config to factors August 16, 2024 07:47
@rylev rylev marked this pull request as ready for review August 16, 2024 07:49
@rylev rylev merged commit 3220350 into factors Aug 16, 2024
1 check passed
@rylev rylev deleted the key-value-trigger2 branch August 16, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants