syumai / workers

Go package to run an HTTP server on Cloudflare Workers.
MIT License
629 stars 39 forks source link

build tags so that the code could run on Cloudflare and Wazero #123

Open gedw99 opened 1 month ago

gedw99 commented 1 month ago

I am having a lot of success with workers, but would love to be able to run the workers on Wazero too.

Should we use build tags so that we can run the WASM on Cloud flare but also Wazero ?

syumai commented 1 month ago

@gedw99 This sounds interesting. Could you please give an example of what kind of program you would like to run on both workers and wazero?

gedw99 commented 1 month ago

Hey @syumai

I am wrote this up a bit better now.

Programs that live on your origin server, but where certain things can be offloaded also to CF works, CF R2, etc

For example Pocketbase is a very cable server with a SQLITE DB etc. You would run that on your Origin Server. Maybe Hetzner or Fly.io.

Then you have all the processing that your need to do, which will use the Pocketbase Sever. These processes represent web pages or anything. The point is that if we can run them on the Origin server AND on Cloud flare workers, we can offload work from the Origin server.

Because each wasm file cant be very big the idea is that each Page is its own was file. These can run on Origin under Wazero or on CF.

They both will call the Pocketbase server to access data and do advanced Auth flows that Pocktbase can do.

As far as I know the only thing we need to do this is for the Fetch call to be able to run on CF and not on CF. You already. have the asset gen cmd. Maybe a similar thing for the Fetch layer too, so that it's flexible for different runtimes.

https://github.com/dispatchrun/net/network/dependents has examples

https://github.com/vasilev/HTTP-request-from-inside-WASM is one example.