Skip to content

liamwh/wasmCloud-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

☁️ Liam's wasmCloud Playground 🎡

Introduction

This repo is for building Proof-of-Concept (PoC) wasmCloud applications. The goal is to deepen my understanding of wasmCloud, its internals, its strengths, its weaknesses, and how the developer experience (DX) is when building applications with it.

Getting Started

The below steps will guide you through setting up the wasmCloud stack and deploying both a Rust and Go Actors & capability providers. Finally we will explore integrating both actors, and integrating an access control solution.

Pre-requisites

  1. Install the pre-requisites:
    • just
    • Docker & Docker Compose
    • wash (wasmCloud CLI)
    • Rust
    • Go & TinyGo if wanting to compile a Go component.

Running the wasmCloud Stack

  1. Run just up to start the docker compose stack running to the wasmCloud components and dashboard UI, accessible at localhost:3030.

Deploy a Rust App (Actor and Provider)

  1. cd into the hello-rust directory and run wash build. This builds the component in ../build directory, which is mounted inside the wasmCloud container as specified in the Docker compose.yaml file.
  2. Still in the hello-rust directory, run just deploy (which runs wash app deploy wadm.yaml under the hood) to deploy the hello application. This includes a http capability provider and an actor listening on localhost:8061.
  3. Run curl localhost:8061 to see the actor's response.

Rust App Troubleshooting

  • You may need to install Rust.
  • You may need to add the wasi32-wasi target.
    • It is installed by running rustup target add wasm32-wasi

Deploy a Go App (Actor and Provider)

  1. cd into the hello-go directory and run wash build. This builds the component in ../build directory, which is mounted inside the wasmCloud container as specified in the Docker compose.yaml file.
  2. Still in the hello-go directory, run just deploy (which runs wash app deploy wadm.yaml under the hood) to deploy the hello application. This includes a http capability provider and an actor listening on localhost:8062.
  3. Run curl localhost:8062 to see the actor's response.

Go App Troubleshooting

Miscellaneous Tips

  • Port forward with just port-forward-nats to be able to use wash against the k8s instance of NATS (which is what wash uses to interact with wasmCloud).

  • You can use wash spy {actor_id} to see the interactions of an actor. As of 26-03-2024, you must enable WASH_EXPERIMENTAL to use this feature. Example output:

    ❯ WASH_EXPERIMENTAL=true wash spy MAGFAN3NPIDLH3W63R3BMXIEAQATMRVZ4L3BI6DNYA324ZKO4CUHCXR6
    Spying on actor MAGFAN3NPIDLH3W63R3BMXIEAQATMRVZ4L3BI6DNYA324ZKO4CUHCXR6
    
    [2024-03-26 19:27:13.838474712 +01:00]
    From: HTTP Server
    To: MAGFAN3NPIDLH3W63R3BMXIEAQATMRVZ4L3BI6DNYA324ZKO4CUHCXR6
    Host: NDHZQJ4HIDR6IWI3XDOVPWPGCN5JNK4JKJHJ6D3GUTYGMGHNSXT6MKEN
    
    Operation: HttpServer.HandleRequest
    Message: {
    "method": "GET",
    "path": "/",
    "queryString": "",
    "header": {
        "host": [
        "localhost:8061"
        ],
        "user-agent": [
        "curl/8.6.0"
        ],
        "accept": [
        "*/*"
        ]
    },
    "body": []
    }