Phisn
CDCloudflare Developers
•Created by MetalGear on 9/12/2023 in #workers-help
What Architecture on workers?
The only public project that comes to my head is https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/. Its neither serverless nor nodejs but explains some nice architectural concepts. (github: https://github.com/dotnet-architecture/eShopOnContainers/wiki/Architecture)
5 replies
CDCloudflare Developers
•Created by MetalGear on 9/12/2023 in #workers-help
What Architecture on workers?
You could maybe use some ddd related architecture to handle your events. One approach I have read about is to have your usual domain layer with entities. When you interact with these entities they generate events (saved in their internal state) which are later published when the entity is saved back into your storage. Now you could publish these events into a queue and have triggers to consume these and so forth.
5 replies
CDCloudflare Developers
•Created by avnav on 9/9/2023 in #workers-help
DEV vs PROD envs
What you could do is use different scripts for different environments. One
npm dev
and npm dev:prod
. They both would no run different scripts in your packages. Specifically in your worker you would start it with something like wrangler ... --vars=DEV_OR_PROD:PROD
or :DEV
. For deployment you would just use your wrangler.toml vars.4 replies
CDCloudflare Developers
•Created by Phisn on 9/8/2023 in #workers-help
Webassembly in libraries not correctly loading
Now I can simply import the wasm file inside my cloudflare worker:
4 replies
CDCloudflare Developers
•Created by Phisn on 9/8/2023 in #workers-help
Webassembly in libraries not correctly loading
Solution:
Found a solution to my problem. Probably the most hacky thing ever but works perfectly and there seems currently to not be a better solution. Rapier is build using wasm-bindgen for js so this applies to my problem https://developers.cloudflare.com/workers/runtime-apis/webassembly/rust/#javascript-plumbing-wasm-bindgen. Its said that we get a Module instead of an Instance and have therefore to adjust the processing that is normally done by bindgen. Problem is, that the proposed solution does not work because of how vite handles wasm files. Therefor my solution was to inject a __setWasm into the _bg file and set it somewhere inside my cloudflare worker. This way the compilation for vite stays uneffected.
I am using the following script as "postinstall" in my package.json:
4 replies
CDCloudflare Developers
•Created by Phisn on 9/8/2023 in #workers-help
Webassembly in libraries not correctly loading
Update:
Wrangler seems to handle the package incorrectly. At least the bundled code does look abviously wrong without any WebAssembly.intiate call. Question is why vite is able to produce correct output and how I can fix the wrangler output.
4 replies