fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.18k stars 247 forks source link

indexdb #494

Open gedw99 opened 2 years ago

gedw99 commented 2 years ago

This is my first interaction with this project. I really like the way its designed. Especially the layering being clear and easy to understand.

Since the aim of the project is to support WASM and WASI it would be cool to support indexeddb for both compile targets

https://pkg.go.dev/github.com/hack-pad/go-indexeddb/idb works in WASM

There is i believe a golang server side indexdb also. I just need to find it.

bacongobbler commented 2 years ago

Hi @gedw99!

It sounds like someone in the open source community needs to write a WASI compatible IndexedDB library. Once that has been accomplished, anyone should be able to write an application talking to IndexedDB, compile it to WASI, and run it with Spin. The only catch there being the ability to run IndexedDB outside the browser. Does that sound right to you?

gedw99 commented 2 years ago

Hey @bacongobbler

Yep it does sounds right and thanks for looking at this.

The native side: https://github.com/huffduff/go-indexeddb The browser side : https://github.com/hack-pad/go-indexeddb

I have not checked if the interface is the same for both at the golang api level yet...

Also no idea where to start writing a WASI compliant API for that interface. I am a golang dev, not rusty... I don't know it its tightly coupled to spin either... Maybe you can advise me ?

Like the Spin Redis, Spin provides the API and the dev calls the IndexedDB api from their WASI Module, Sort of like Cloudflare KV store: https://developers.cloudflare.com/workers/learning/how-kv-works/

gedw99 commented 2 years ago

There is also another option here.

https://github.com/hack-pad/hackpadfs is a FS that runs in a browser, native ( desktop server, mobile) and remote ( via s3). Its a factory pattern i guess. The browser version uses Indexeddb as the actual durable store.

Example usage: https://github.com/hack-pad/hackpad/blob/main/internal/fs/

Its actually a golang compiler that runs inside the Browser btw - yeah nuts but cool but nuts :) The golang compiler is WASM itself.