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

feature: enable Deno KV for Deno #4145

Open
thoughtpolice opened this issue Jul 28, 2024 · 2 comments
Open

feature: enable Deno KV for Deno #4145

thoughtpolice opened this issue Jul 28, 2024 · 2 comments
Assignees

Comments

@thoughtpolice
Copy link

thoughtpolice commented Jul 28, 2024

Deno KV is a key-value store API for Deno that will be going stable in 2.0. I'd like it if the API was available to my Windmill scripts.

Normally, KV wouldn't make much sense for Windmill because Deno.openKv() by itself just opens a local (sqlite) database on the filesystem and such local state doesn't have a clear lifetime. But a very neat feature is that you can also use Deno KV with remote servers, and therefore with multiple Deno processes, by calling openKv("https://kv.example.com:4512"), where that URL points to either Deno Cloud or a locally running denokv service that you host yourself.

My motivation is that I have a long-running service[1] written in Deno that does not use Windmill, but I want to have some Windmill scripts and flows that it works in tandem with. Therefore, I'd like my service and my (Deno) Windmill scripts to both use openKv with a shared server for shared state; for example a Windmill script might be invoked and write some data to the database that the outside service can read later.

This feature can be enabled with the --unstable-kv flag passed to the runtime. Based on 8d5c7c2 (found via blame) which added a similar flag, it seems pretty easy to fix this, if a patch would be acceptable.


[1] In theory it could use Windmill, it's a pure Deno script, but for various reasons I'd really like it to be a persistently running service which has a clear persistent lifetime (e.g. the typical cold start concerns). What I really want it something like deno serve as a first-class concept in Windmill, but I realize that's a different discussion entirely...

@thoughtpolice
Copy link
Author

Oh, I forgot that you also need to set the DENO_KV_ACCESS_TOKEN environment variable in the context of deno for this to work, which is the access token for the endpoint. That should work well enough with contextual variables, I think. It would be more ideal if you could have per script/flow/app contextual variables instead of just per-workspace variables, but I can manage for now.

@rubenfiszel
Copy link
Contributor

rubenfiszel commented Jul 28, 2024 via email

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

No branches or pull requests

2 participants