Skip to content

Latest commit

 

History

History
 
 

http-echo-tinygo

HTTP Echo (TinyGo)


This repository contains a Web Assembly System Interface ("WASI") and Component Model enabled WebAssembly component example of a Golang (in this case TinyGo), built to run on wasmCloud.

Warning The WASI & the Component Model specifications are still undergoing changes and iterating quickly, so support inside wasmCloud is functional, but experimental.

You may see the mention of things like "preview2" or "preview3" -- these represent phases of the in-progress specification, standardization, and implementation efforts which could cause breaking changes.

Put on your cowboy hat ( 🤠 ) and enjoy the ride. File issues if/when it gets bumpy.

Quickstart

Install dependencies

Before starting, ensure that you have the following installed:

Build the WASI component

Once you have these two things, build the project locally:

wash build

After the project, you'll have a couple new folders, most importantly the build folder:

build
├── http-echo-tinygo-component_s.wasm
└── http-echo-tinygo-component.wasm

build/http-echo-tinygo-component_s.wasm is the WebAssembly module, signed with it's required capabilities, and ready to run on a wasmCloud lattice.

Start wasmCloud

Start wasmCloud, in a separate terminal:

wash up --nats-websocket-port 4223

Warning This demo works with [wasmCloud host versions 0.81.0 or newer][host-v0.81.0].

Optionally, you can also start the UI by running (in a separate terminal):

wash ui

Deploy this application

We can deploy the local project using the wasmCloud declarative deployment engine, wadm.

First, edit wadm.yaml to include the absolute path to the signed WebAssembly module:

# ....
  components:
    - name: http-echo-tinygo
      type: component
      properties:
-        # TODO: you must replace the path below to match your genreated code in build
-       image: file:///absolute/path/to/this/repo/build/http-echo-tinygo_s.wasm
+       image: file:///the/absolute/path/to/build/http-echo-tinygo-component_s.wasm
      traits:
# ...

Then, deploy using wash:

wash app deploy --replace wadm.yaml

You can use wash app subcommand to do much more -- checking the list of applications, delete applications, and more.

For example, if you'd like to remove the previously deployed version of this project:

wash app delete http-echo-tinygo-component v0.0.1

Development

Running tests

To run tests for this example:

cd tests
go test -tags e2e

Information Note that the tests use go, not tinygo, and require wash to be installed