-
Notifications
You must be signed in to change notification settings - Fork 257
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
Add Azure CosmosDB implementation for KV #1463
Conversation
async fn get_keys(&self) -> Result<Vec<String>, Error> { | ||
let client = self.client.lock().await; | ||
let query = client | ||
.query_documents(Query::new("SELECT * FROM c".to_string())) |
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 think we can tweak the query to only return c.id
instead of the entire document?
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.
Looking good!
06587d7
to
ae62288
Compare
This commit adds an implementation of Azure CosmosDB as a backend for Spin's key/value store. Specifically, this uses a CosmosDB account created with the NoSQL API, and requires the following contents for the runtime configuration file: ```toml [key_value_store.default] type = "azure_cosmos" key = "<key>" account = "<cosmos-account>" database = "<cosmos-database>" container = "<cosmos-container>" The CosmosDB container *must* be created with the default partition key, `/id`. To test the changes in this commit, the runtime configuration file above can be passed (and can be further tested with the KV explorer template): ```bash $ spin up --runtime-config-file runtime-config.toml --key-value keyfromcli=valuefromcli Storing default key-value data to Azure CosmosDB ``` Signed-off-by: Radu Matei <radu.matei@fermyon.com> Update CosmosDB backend for KV Signed-off-by: Radu Matei <radu.matei@fermyon.com> Update CosmosDB backend for KV Signed-off-by: Radu Matei <radu.matei@fermyon.com> Update CosmosDB backend for KV Signed-off-by: Radu Matei <radu.matei@fermyon.com>
ae62288
to
4a93396
Compare
This commit removes the `OnceCell` dependency from the Azure CosmosDB backend for KV and simplifies the client setup and creation. Co-authored-by: Ryan Levick <ryan.levick@fermyon.com> Signed-off-by: Radu Matei <radu.matei@fermyon.com>
Signed-off-by: Radu Matei <radu.matei@fermyon.com>
@rylev and I paired on this earlier today and addressed most of the feedback. This should be ready for a re-review. Thanks! |
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.
LGTM! Just have one comment there.
The Spin key-value API for `delete` states that "no error is raised if a tuple did not previously exist for key". This commit updates the Azure CosmosDB implementation to follow that. Signed-off-by: Radu Matei <radu.matei@fermyon.com>
Signed-off-by: Radu Matei <radu.matei@fermyon.com>
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.
Documentation for this is being worked on at fermyon/developer#611 and fermyon/developer#648 |
This commit adds an implementation of Azure CosmosDB as a backend for Spin's key/value store.
Specifically, this uses a CosmosDB account created with the NoSQL API, and requires the following contents for the runtime configuration file:
The CosmosDB container must be created with the default partition key,
/id
:To test the changes in this commit, the runtime configuration file above
can be passed (and can be further tested with the KV explorer template):
Thanks to @fibonacci1729 for pairing on this one!
cc @Mossaka @devigned