-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
factors: key value tests, doc comments, and Azure factor
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
- Loading branch information
1 parent
7c6faed
commit 1a4615a
Showing
12 changed files
with
414 additions
and
9 deletions.
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,35 @@ | ||
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
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.