-
Notifications
You must be signed in to change notification settings - Fork 255
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 tests, doc comments, and Azure factor #2666
Merged
kate-goldenring
merged 2 commits into
fermyon:factors
from
kate-goldenring:key-value-factor-cleanups
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "spin-factor-key-value-azure" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
serde = { version = "1.0", features = ["rc"] } | ||
spin-factor-key-value = { path = "../factor-key-value" } | ||
# TODO: merge with this crate | ||
spin-key-value-azure = { path = "../key-value-azure" } | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use serde::Deserialize; | ||
use spin_factor_key_value::MakeKeyValueStore; | ||
use spin_key_value_azure::KeyValueAzureCosmos; | ||
|
||
/// A key-value store that uses Azure Cosmos as the backend. | ||
pub struct AzureKeyValueStore; | ||
|
||
/// Runtime configuration for the Azure Cosmos key-value store. | ||
#[derive(Deserialize)] | ||
pub struct AzureCosmosKeyValueRuntimeConfig { | ||
/// The authorization token for the Azure Cosmos DB account. | ||
key: String, | ||
/// The Azure Cosmos DB account name. | ||
account: String, | ||
/// The Azure Cosmos DB database. | ||
database: String, | ||
/// The Azure Cosmos DB container where data is stored. | ||
/// The CosmosDB container must be created with the default partition key, /id | ||
container: String, | ||
} | ||
|
||
impl MakeKeyValueStore for AzureKeyValueStore { | ||
const RUNTIME_CONFIG_TYPE: &'static str = "azure_cosmos"; | ||
|
||
type RuntimeConfig = AzureCosmosKeyValueRuntimeConfig; | ||
|
||
type StoreManager = KeyValueAzureCosmos; | ||
|
||
fn make_store( | ||
&self, | ||
runtime_config: Self::RuntimeConfig, | ||
) -> anyhow::Result<Self::StoreManager> { | ||
KeyValueAzureCosmos::new( | ||
runtime_config.key, | ||
runtime_config.account, | ||
runtime_config.database, | ||
runtime_config.container, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 know that naming is a bit up in the air especially since we have a bunch of crates that will eventually go away, but I wonder if we already have an idea if this naming convention is worth keeping.
Imaging a world where the transition to factors is complete, I would personally like to see the following naming conventions:
factor-$import
(e.g.,factor-llm
orfactor-key-value
). Even in a world where factors are not new, I think naming the crates withfactor
makes sense so that we can quickly see where all of the factors are defined. This is always a reason to start withfactor_
so that all of the factors are bundled together.$import-$impl_specific_description
(e.g.,key-value-azure
orsqlite-local-database
). Keeping the kind of import first, means all related implementations will be bundled (e.g., everything key-value related will be bundled).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.
Right now, it seems like the majority of our crates are
spin
prefixed for this discoverability reasonThe shim does and will likely continue to use these KV factors that the spin CLI uses. I wouldn't put Spin CLI ownership on them. Could it be assumed that if the naming scheme is
spin-factor-$import
then it is a factor and if it has a suffix with$impl_specific_description
(spin-factor-$import-$impl_specific_description
) then it is a specific implementation that a runtime could use. It just happens to be that the Spin CLI runtime authored the implementation