Skip to content

Commit

Permalink
Merge branch 'main' into update-pipeline-for-multi-channel-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
lachieh authored Oct 23, 2023
2 parents 4103925 + e37b8d6 commit 1d22cba
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 18 deletions.
File renamed without changes
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Awesome projects and source code for the [Things To Build](https://cosmonic.com/

| Deployment | Link | Topology |
| ------------- | ------------- | ------------- |
| Hello World on Cosmonic | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/hello-world/hello-cosmonic.wadm) | This example will deploy Hello World actor and HTTP Server Provider all on Cosmonic. |
| Hello World on Stargate | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/hello-world/hello-stargate.wadm) | This example will deploy Hello World on a remote stargate node, and the HTTP Server Provider on Cosmonic. In order for this manifest to work you will need at least one stargate host deployed. |
| XKCD Generator on Cosmonic | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/xkcdgenerator/xkcd-generator-cosmonic.wadm) | This example will deploy the XKCD actor, HTTP Client Provider, and HTTP Server Provider all on Cosmonic. |
| XKCD Generator on Stargate | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/xkcdgenerator/xkcd-generator-stargate.wadm) | This example will deploy the XKCD actor & HTTP Client Provider on a remote stargate node, and the HTTP Server Provider on Cosmonic. In order for this manifest to work you will need at least one stargate host deployed. |
| Hello World on Cosmonic | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/hello-world/hello-cosmonic.wadm.yaml) | This example will deploy Hello World actor and HTTP Server Provider all on Cosmonic. |
| Hello World on Stargate | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/hello-world/hello-stargate.wadm.yaml) | This example will deploy Hello World on a remote stargate node, and the HTTP Server Provider on Cosmonic. In order for this manifest to work you will need at least one stargate host deployed. |
| XKCD Generator on Cosmonic | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/xkcdgenerator/xkcd-generator-cosmonic.wadm.yaml) | This example will deploy the XKCD actor, HTTP Client Provider, and HTTP Server Provider all on Cosmonic. |
| XKCD Generator on Stargate | [<img src="https://cosmonic.com/badge/deploy.svg" alt="Deploy on Cosmonic" width="400">](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/xkcdgenerator/xkcd-generator-stargate.wadm.yaml) | This example will deploy the XKCD actor & HTTP Client Provider on a remote stargate node, and the HTTP Server Provider on Cosmonic. In order for this manifest to work you will need at least one stargate host deployed. |


# How does it work?
Expand All @@ -32,9 +32,9 @@ You can define your own labels and leverage them to _manage_ your application.
## Application Version Control
Using the above manifests you can deploy multiple versions of your application and easily switch between different deployment topologies. Many of the applications have the same name, such as ```xkcd``` and different ```versions```. On Cosmonic, find the controls under Applications --> App --> Versions:

![Cosmonic Applications Version Control Screen Shot](./img/cosmonic-applications-versions.png)
![Cosmonic Applications Version Control Screen Shot](./.assets/cosmonic-applications-versions.png)

If you inspect two different versions of an application manifest you can see how the different tags change the application topology. In the above example for the ```xkcd``` Application you can see two different versions: [v1-cosmonic](./xkcdgenerator/xkcd-generator-cosmonic.wadm) and [v1-stargate](./xkcdgenerator/xkcd-generator-stargate.wadm). As you can see below, the two key differences are the ```version:``` tag and then the tags under a components ```requirements:```. You can see we direct WADM to deploy the components to the stargate hosts using the ```stargate: 'true'``` tag; it is commented out but I could further direct this component by using a tag such as ```hostcore.os: macos```.


![Cosmonic Applications Version Control Screen Shot](./img/wadm-diff-xkcd-cosmonic-and-stargate.png)
![Cosmonic Applications Version Control Screen Shot](./.assets/wadm-diff-xkcd-cosmonic-and-stargate.png)
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ kind: Application
metadata:
name: hello
annotations:
version: v0.0.1-cosmonic
version: v1.0.0-cosmonic
description: "Cosmonic Hello World Example"
spec:
components:
- name: hello
type: actor
properties:
image: wasmcloud.azurecr.io/hello:0.1.7
image: cosmonic.azurecr.io/hello:0.1.0
traits:
- type: spreadscaler
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ kind: Application
metadata:
name: hello
annotations:
version: v0.0.1-stargate
version: v1.0.0-stargate
description: "Cosmonic Hello World Example"
spec:
components:
- name: hello
type: actor
properties:
image: wasmcloud.azurecr.io/hello:0.1.7
image: cosmonic.azurecr.io/hello:0.1.0
traits:
- properties:
replicas: 1
Expand Down
54 changes: 54 additions & 0 deletions kvcounter/kvcounter.wadm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This is a full example of how to run the kvcounter actor exposed with the
# managed providers for the HTTP and KeyValue capabilities.

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: kvcounter
annotations:
version: v1.0.0
description: "wasmCloud Key Value Counter Example"
spec:
components:
- name: kvcounter
type: actor
properties:
image: cosmonic.azurecr.io/kvcounter:0.1.0
traits:
- type: spreadscaler
properties:
replicas: 1
- type: linkdef
properties:
target: keyvalue
- type: linkdef
properties:
target: httpserver
values:
ADDRESS: 0.0.0.0:8081
- name: httpserver
type: capability
properties:
image: cosmonic.azurecr.io/httpserver_wormhole:0.5.4
contract: wasmcloud:httpserver
traits:
- type: spreadscaler
properties:
replicas: 1
spread:
- name: wormholespread
requirements:
cosmonic_managed: 'true'
- name: keyvalue
type: capability
properties:
image: cosmonic.azurecr.io/builtin_keyvalue:0.2.4
contract: wasmcloud:keyvalue
traits:
- type: spreadscaler
properties:
replicas: 1
spread:
- name: kvspread
requirements:
cosmonic_managed: 'true'
98 changes: 97 additions & 1 deletion multi-channel-chat/multi-channel-chat.wadm.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,97 @@
# WIP
# This is a full example of a multi-channel chat application. It uses the following components:
# - chatlog: A wasmCloud actor that stores the chat log in a key-value store
# - httpchannel: A wasmCloud actor that uses the HTTP Server provider to listen for HTTP requests
# - natschannel: A wasmCloud actor that uses the NATS Messaging provider to listen for NATS messages
# - apigateway: A wasmCloud actor thas is invoked through actor-to-actor calls to coordinate messages between the channels

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: multi-channel-chat
annotations:
version: v1.0.0
description: "Multi-Channel Chat"
spec:
components:
- name: apigateway
type: actor
properties:
image: cosmonic.azurecr.io/mcc_apigateway:0.1.0
traits:
- type: spreadscaler
properties:
replicas: 1

- name: chatlog
type: actor
properties:
image: cosmonic.azurecr.io/mcc_chatlog:0.1.0
traits:
- type: spreadscaler
properties:
replicas: 1
- type: linkdef
properties:
target: keyvalue

- name: httpchannel
type: actor
properties:
image: cosmonic.azurecr.io/mcc_httpchannel:0.1.0
traits:
- type: spreadscaler
properties:
replicas: 1
- type: linkdef
properties:
target: httpserver

- name: natschannel
type: actor
properties:
image: cosmonic.azurecr.io/mcc_natschannel:0.1.0
traits:
- type: spreadscaler
properties:
replicas: 3
- type: linkdef
properties:
target: messaging

- name: httpserver
type: capability
properties:
contract: wasmcloud:httpserver
image: cosmonic.azurecr.io/httpserver_wormhole:0.5.4
traits:
- type: spreadscaler
properties:
replicas: 1
spread:
- name: wormholespread
requirements:
cosmonic_managed: 'true'

- name: keyvalue
type: capability
properties:
contract: wasmcloud:keyvalue
image: cosmonic.azurecr.io/builtin_keyvalue:0.2.4
traits:
- type: spreadscaler
properties:
replicas: 1
spread:
- name: kvspread
requirements:
cosmonic_managed: 'true'

- name: messaging
type: capability
properties:
contract: wasmcloud:messaging
image: wasmcloud.azurecr.io/nats_messaging:0.17.2
traits:
- type: spreadscaler
properties:
replicas: 1
2 changes: 1 addition & 1 deletion xkcdgenerator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Click on the button below to launch the XKCD Generator on Cosmonic Now:

[![Deploy on Cosmonic](https://cosmonic.com/badge/deploy.svg)](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/xkcdgenerator/xkcd-generator-cosmonic.wadm)
[![Deploy on Cosmonic](https://cosmonic.com/badge/deploy.svg)](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/main/xkcdgenerator/xkcd-generator-cosmonic.wadm.yaml)

The XKCD image generator application is a simple HTTP application that randomly produces random XKCD comics on demand. It illustrates how to build a fully functioning application with a single actor and a few capability providers. You can find the inspiration and architecture diagram for this application in the [Cosmonic documentation](https://cosmonic.com/docs/to-build/image-generator#architecture-and-design).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
annotations:
description: wasmCloud XKCD Example
version: v1.1-cosmonic-xkcd
description: wasmCloud XKCD Example (Cosmonic Managed)
version: v1.0.0-managed
name: xkcd
spec:
components:
Expand All @@ -56,7 +56,7 @@ spec:
# Source for this image: https://github.com/cosmonic/awesome-cosmonic/blob/main/xkcdgenerator/src/lib.rs
# With Cosmonic developers are responsible for their business logic, leveraging WebAssembly Components
#
image: ghcr.io/liamrandall/xkcd:0.3.0.5
image: cosmonic.azurecr.io/xkcdgenerator:0.1.0
traits:
- properties:
replicas: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
annotations:
description: wasmCloud XKCD Example
version: v1-stargate
description: wasmCloud XKCD Example (Stargate Hosted)
version: v1.0.0-stargate
name: xkcd
spec:
components:
- name: xkcd
properties:
image: wasmcloud.azurecr.io/xkcd:0.1.7
image: cosmonic.azurecr.io/xkcdgenerator:0.1.0
traits:
- properties:
replicas: 1
Expand Down

0 comments on commit 1d22cba

Please sign in to comment.