earthstar-project / earthstar

Storage for private, distributed, offline-first applications.
https://earthstar-project.org
GNU Lesser General Public License v3.0
623 stars 18 forks source link

Adding denoKV to doc drivers #326

Open ssv0 opened 3 months ago

ssv0 commented 3 months ago

Hi, sneakspeak dev here: to make earthstar server deployable on "deno deploy" I added support to denokv doc driver, modding localstorage driver. So if you look to add support for deno kv the modded driver is in this repo:

https://github.com/ssv0/denodeploy-denokv

Feel free to take inspiration or add it to main repo. Maybe it would be better to use different keys instead of putting all docs in an entry.

sgwilym commented 3 months ago

Thank you for sharing this, and for creating this driver.

I see that you use the memory attachment driver, do you not use attachments? How is sync on deno deploy? Do the websocket connections live long enough for sync to happen?

You're right that putting data in different keys would be (vastly) better than a single entry. The reason that this approach is workable with LocalStorage is because it can store a maximum of 5mb. Deno KV can take much more, so performance will degrade as the number of stored docs grows.

The next version of Earthstar will have a ground-up Deno.KV driver via willow-js: https://github.com/earthstar-project/willow-js/blob/main/src/store/storage/kv/kv_driver_deno.ts

There will be initial builds of willow-powered Earthstar in the coming months. Would you be interested in trying it, and seeing how it is to migrate sneakspeak to it?

ssv0 commented 3 months ago

I still have to test denokv, as far as I know there seem to be problems when new instances are launched with an existing (because it's global) kv but maybe I just misconfigured the client. I think sneakspeak will benefit from willow features so I'm definitely trying it out.

sgwilym commented 1 month ago

@ssv0 Sorry, realised I never updated you on this. Earthstar 11 now has a beta available: https://jsr.io/@earthstar/earthstar@11.0.0-beta.3

Soon it'll also get sneakernet-style capabilities via Willow's new sideloading protocol.