Examples
ARCHIVED: This repository contains examples for pre-1.0 versions of wasmCloud. All examples are now located in the main wasmCloud repository https://github.com/wasmCloud/wasmCloud/tree/main/examples.
Install / Use
/learn @wasmCloud/ExamplesREADME
[!IMPORTANT] The examples in this repository are WebAssembly modules which consume interfaces defined in Smithy and communicate with providers over the stable ABI. Actors built as WebAssembly components consume interfaces defined using WIT. Examples of actor components can be found in the wasmCloud repo. Note that support for WIT is considered experimental at this time.
wasmCloud Examples
Example actors, capability providers, and other demonstrations
Actors
The following actors run as WebAssembly on wasmCloud hosts.
| Example | Description | OCI Reference <br/> (refer to example for latest version) |
| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| animal-image-downloader | An actor that receives messages and makes HTTP requests, downloading a picture of an animal to a blobstore | wasmcloud.azurecr.io/animal-image-downloader |
| echo | An actor that listens on an HTTP port and returns a JSON payload describing the incoming request | wasmcloud.azurecr.io/echo |
| echo-messaging | An actor that listens on a message broker topic and replies | wasmcloud.azurecr.io/echo-messaging |
| hello | Canonical "hello world" actor that listens on an HTTP port and replies with a greeting | wasmcloud.azurecr.io/hello |
| kvcounter | An actor that uses the key-value store to increment a counter and return a value for every HTTP request it receives | wasmcloud.azurecr.io/kvcounter |
| logging | An actor that demonstrates the builtin logging capability provider | wasmcloud.azurecr.io/logging |
| message-pub | An actor that demonstrates receiving HTTP requests and publishing the request body as a message | wasmcloud.azurecr.io/message-pub |
| random | An actor that demonstrates the builtin random number generation capability provider | wasmcloud.azurecr.io/random |
| todo-sql | An todo-application using sql database, https server (with TLS), logging, and numbergen | (unpublished) |
| todo | An todo-application using keyvalue store, http server, and logging | (unpublished) |
| xkcd | A application that generates xkcd comics | wasmcloud.azurecr.io/xkcd |
| ifconfig | A tinygo actor that will return the external IP address of your http client | (unpublished) |
Interfaces
The following example interfaces are defined by Smithy models.
| Example | Description | Capability contract | Rust crate |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------- | ----------------------------- |
| cron | A simple interface for invoking an actor at a specific time | wasmcloud:example:cron | wasmcloud-interface-cron |
| payments | A simple interface for a payments capability provider (used in the Creating an Interface tutorial) | wasmcloud:example:payments | wasmcloud-examples-payments |
| runner | A simple interface with a single 'Run' method | wasmcloud:example:runner | wasmcloud-examples-runner |
| timing | A simple interface for retrieving the current timestamp from the host | wasmcloud:timing | wasmcloud-interface-timing |
Capability providers
Providers of capabilities for wasmCloud actors
| Example | Description | Capability contract | OCI Reference |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cron | A capability provider that uses cron expressions to invoke actors on a timed interval | wasmcloud:example:cron | wasmcloud.azurecr.io/cron |
| factorial | A capability provider that computes factorial of a number | wasmcloud:example:payments | wasmcloud.azurecr.io/factorial |
| fakepay | A simple payment provider, used in the Creating a capability provider tutorial | wasmcloud:example:fakepay | wasmcloud.azurecr.io/fakepay |
| timing | An implementation of the wasmcloud:timing capability contract | wasmcloud:timing | |
Applications
| Example | Description | | ---------------------------------------------------------------------- | --------------------------------------------------
