-
Notifications
You must be signed in to change notification settings - Fork 259
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
Conversation
Signed-off-by: Ryan Levick <[email protected]>
335851e
to
3c26407
Compare
Signed-off-by: Ryan Levick <[email protected]>
3c26407
to
e42b249
Compare
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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...
// Unwraps are safe because the store types are known to not overlap. | |
// Unwraps are fine because the store types are known to not overlap. |
There was a problem hiding this comment.
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.
Builds on #2711 so marking as draft until that merges
This moves runtime config handling for Spin CLI to its own crate.