Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 2.77 KB

README.md

File metadata and controls

45 lines (35 loc) · 2.77 KB

WASM-Handler

Go App that listens to websocket connections at:

  • /format: to format the Go code
  • /compile: to compile the input code into a WASM (throws error if it fails)

Format Rust code

Message Format:

  • Input Base64(input rust code)
  • Output Base64({Success:true/false, Data:(Base64 encoded input rust formatted code)})
Input: IyFbbm9fc3RkXQp1c2Ugc29yb2Jhbl9zZGs6Ontjb250cmFjdGltcGwsIHZlYywgRW52LCBTeW1ib2wsIFZlY307CnB1YiBzdHJ1Y3QgQ29udHJhY3Q7CiNbY29udHJhY3RpbXBsXQppbXBsIENvbnRyYWN0IHsKICAgICAgICAgICAgICBwdWIgZm4gaGVsbG8oZW52OiBFbnYsIHRvOiBTeW1ib2wpIC0+IFZlYzxTeW1ib2w+IHsKICAgICAgICB2ZWMhWyZlbnYsIFN5bWJvbDo6c2hvcnQoIkhlbGxvIiksIHRvXQogICAgfQp9Cg==

Output:
eyJTdWNjZXNzIjp0cnVlLCJEYXRhIjoiSXlGYmJtOWZjM1JrWFFwMWMyVWdjMjl5YjJKaGJsOXpaR3M2T250amIyNTBjbUZqZEdsdGNHd3NJSFpsWXl3Z1JXNTJMQ0JUZVcxaWIyd3NJRlpsWTMwN0NuQjFZaUJ6ZEhKMVkzUWdRMjl1ZEhKaFkzUTdDaU5iWTI5dWRISmhZM1JwYlhCc1hRcHBiWEJzSUVOdmJuUnlZV04wSUhzS0lDQWdJSEIxWWlCbWJpQm9aV3hzYnlobGJuWTZJRVZ1ZGl3Z2RHODZJRk41YldKdmJDa2dMVDRnVm1WalBGTjViV0p2YkQ0Z2V3b2dJQ0FnSUNBZ0lIWmxZeUZiSm1WdWRpd2dVM2x0WW05c09qcHphRzl5ZENnaVNHVnNiRzhpS1N3Z2RHOWRDaUFnSUNCOUNuMEsifQ

Compile WASM from Rust code

Message Format:

  • Input {CargoToml:Base64(cargoToml), MainRs:Base64(rust_file)}
  • Output Base64({Id: Redis_key,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czZDcwIiwiU3VjY2VzcyI6dHJ1ZSwiTWVzc2FnZSI6IkNvbXBpbGF0aW9uIHN1Y2Nlc3NmdWwhIn0=

Redis

It also uses Redis as a caching service for the compile functionality to prevent same repeatative builds also leading to faster response times.

Redis Data Format:

key: md5(base64(cargoToml+mainRs))

value:
    base64
    (
        Success: true/false,
        Message: base64(compiler output),
        Wasm: base64(wasm file content)
    )