Skip to content

Latest commit

 

History

History
 
 

http-echo-tinygo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

HTTP Echo (TinyGo)


This repository contains a Web Assembly System Interface ("WASI") and Component Model enabled actor 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 actor

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:

WASMCLOUD_VERSION=v0.80.0 wash up --nats-websocket-port 4001

Warning This demo works with wasmCloud host version 0.80.0.

Please ensure that you use either WASMCLOUD_VERSION (via ENV) or --wasmcloud-version=v0.80.0 when executing commands like wash up

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

wash ui --experimental

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: actor
      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 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