A job is a combination of some WASM code and a payload for it to operate on. These pairings are defined in .jobdef files.
Jobs are executed by the runner in your web browser.
npm installnpm startopen http://localhost:8000/#24
Assuming everything is working, you should see this in your console:
[SCHEDULER] Worker completed successfully: Hello, world!
- The runner connected to the backend and requested the code and payload for the job with id
24(which was specified in the URL) - The runner instantiated a new WebAssembly instance, copied the payload into its memory, and ran its
mainfunction - The job took its payload (which was the string
world), inserted it into the string"Hello, " + payload + "!", and passed the result back to the runner - The runner stopped the job
- Open up
public/jobs/hello-world.txt - Replace the word "world" with your name and save the file
- Enqueue a job with your new payload: run
bin/swasm-create public/jobs/hello-world.jobdef
Your terminal should have a line along these lines:
If you want to run this specific job: http://localhost:8000/#25
Open that URL up and you should see your customized greeting.
- Open up
public/jobs/hello-world.ts - Change the word "Hello" to "Ahoy" and save the file
- Compile the code with
bin/compile public/jobs/hello-world.ts
Repeat the steps from above to enqueue a job with your new code.
It's a pain to have to enqueue a new job every time you want to run your code, so there's also a debug mode.
Open up localhost:8000/debug.html#hello-world to run the hello-world in debug mode. This runs the code directly from the local server (specifically the file public/jobs/hello-world.wasm), and runs it against a pre-defined payload.
You can find the pre-defined debug payloads inside of client/js/debug.js.