Skip to content

Commit

Permalink
📦 updates modules for v0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
k33g committed Apr 20, 2023
1 parent 8253cde commit 49c66ed
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 46 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Capsule: the nano (wasm) functions runner

- 🖐 Issues: [https://github.com/bots-garden/capsule/issues](https://github.com/bots-garden/capsule/issues)
- 📦 Last release: `v0.3.2 🤗 [WASM I/O 2023]`
- 📦 Next release: `v0.3.3 TBD` *🚧 in progress*
- 📦 Last release: `v0.3.3 🍊 [Tangerine]`
- 📦 Next release: `v0.3.4 TBD` *🚧 in progress*
- 📝 Full documentation [https://bots-garden.github.io/capsule/](https://bots-garden.github.io/capsule/)

## What is **Capsule**?
Expand Down
4 changes: 2 additions & 2 deletions capsule-launcher/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/bots-garden/capsule/capsule-launcher

go 1.18
go 1.20

replace (
github.com/bots-garden/capsule/commons => ../commons
Expand All @@ -19,7 +19,7 @@ require (
github.com/gofiber/fiber/v2 v2.42.0
github.com/google/uuid v1.3.0
github.com/nats-io/nats.go v1.24.0
github.com/tetratelabs/wazero v1.0.1
github.com/tetratelabs/wazero v1.0.2
)

require (
Expand Down
4 changes: 2 additions & 2 deletions capsule-launcher/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tetratelabs/wazero v1.0.1 h1:xyWBoGyMjYekG3mEQ/W7xm9E05S89kJ/at696d/9yuc=
github.com/tetratelabs/wazero v1.0.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
github.com/tetratelabs/wazero v1.0.2 h1:lpwL5zczFHk2mxKur98035Gig+Z3vd9JURk6lUdZxXY=
github.com/tetratelabs/wazero v1.0.2/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0=
github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw=
Expand Down
2 changes: 2 additions & 0 deletions capsulemodule/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ replace (
github.com/bots-garden/capsule v0.3.0 => ../
github.com/bots-garden/capsule v0.3.1 => ../
github.com/bots-garden/capsule v0.3.2 => ../
github.com/bots-garden/capsule v0.3.3 => ../
)

replace (
Expand All @@ -32,6 +33,7 @@ replace (
github.com/bots-garden/capsule/commons v0.3.0 => ../commons
github.com/bots-garden/capsule/commons v0.3.1 => ../commons
github.com/bots-garden/capsule/commons v0.3.2 => ../commons
github.com/bots-garden/capsule/commons v0.3.3 => ../commons
)

require github.com/bots-garden/capsule/commons v0.3.1
1 change: 1 addition & 0 deletions commons/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ replace (
github.com/bots-garden/capsule v0.3.0 => ../
github.com/bots-garden/capsule v0.3.1 => ../
github.com/bots-garden/capsule v0.3.2 => ../
github.com/bots-garden/capsule v0.3.3 => ../
)
2 changes: 1 addition & 1 deletion commons/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package commons

func CapsuleVersion() string {
return "v0.3.2 🤗 [WASM I/O 2023]"
return "v0.3.3 🍊 [Tangerine]"
}
2 changes: 1 addition & 1 deletion docs/getting-started-cabu-serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ capsule \
```bash
docker run \
-p 8080:8080 \
-v $(pwd):/app --rm k33g/capsule-launcher:0.3.2 \
-v $(pwd):/app --rm k33g/capsule-launcher:0.3.3 \
/capsule \
-wasm=./app/hello-world.wasm \
-mode=http \
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Capsule: the nano (wasm) functions runner

!!! info "What's new?"
- `v0.3.3 🍊 [Tangerine]`: dependencies updates: wazero to 1.0.1 then 1.0.2 (performances: x 1.4 🚀)
- `v0.3.2 🤗 [WASM I/O 2023]`: dependencies updates: wazero to 1.0.0-pre.9 (Capsule is twice as fast 🚀)
- `v0.3.1 🐊 [Tampa Bay]`: dependencies updates: wazero to 1.0.0-pre.8
- `v0.3.0 🎄 [Christmas tree]`: Refactoring (Capsule is at least 4 times faster than the previous version).
Expand Down
4 changes: 2 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Before executing or running a function, you need to install the last release of
🖐 **On Linux**:

```bash
export CAPSULE_VERSION="v0.3.2"
export CAPSULE_VERSION="v0.3.3"
wget -O - https://raw.githubusercontent.com/bots-garden/capsule/${CAPSULE_VERSION}/install-capsule-launcher.sh| bash
```

Expand All @@ -29,7 +29,7 @@ MESSAGE="👋 Hello World 🌍" capsule \
-httpPort=8080
```

> You can download the appropriate release of **Capsule** here: [`v0.3.2 🤗 [WASM I/O 2023]`](https://github.com/bots-garden/capsule/releases/tag/v0.3.2)
> You can download the appropriate release of **Capsule** here: [`v0.3.3 🍊 [Tangerine]`](https://github.com/bots-garden/capsule/releases/tag/v0.3.3)
## Using the Capsule Docker image
> The documentation is a wip 🚧
Expand Down
2 changes: 1 addition & 1 deletion install-capsule-launcher.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
LAST_CAPSULE_VERSION="v0.3.2"
LAST_CAPSULE_VERSION="v0.3.3"
echo "System: ${OSTYPE} $(uname -m)"

if [ -z "$CAPSULE_PATH" ]
Expand Down
2 changes: 1 addition & 1 deletion sudo.install-capsule-launcher.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
LAST_CAPSULE_VERSION="v0.3.2"
LAST_CAPSULE_VERSION="v0.3.3"
echo "System: ${OSTYPE} $(uname -m)"

if [[ $1 = "help" ]]
Expand Down
2 changes: 1 addition & 1 deletion update-modules-for-release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

TAG="v0.3.2"
TAG="v0.3.3"
cd commons
go mod edit -replace github.com/bots-garden/capsule@${TAG}=../

Expand Down
66 changes: 33 additions & 33 deletions wasm_modules/capsule-hello-post-fastjson/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@ package main

// TinyGo wasm module
import (
hf "github.com/bots-garden/capsule/capsulemodule/hostfunctions"
hf "github.com/bots-garden/capsule/capsulemodule/hostfunctions"

"github.com/valyala/fastjson"
"github.com/valyala/fastjson"
)

// main is required.
func main() {

hf.SetHandleHttp(Handle)
hf.SetHandleHttp(Handle)
}

func Handle(request hf.Request) (response hf.Response, errResp error) {
/*
bodyReq = {"author":"Philippe","message":"Golang 💚 wasm"}
*/
/*
bodyReq = {"author":"Philippe","message":"Golang 💚 wasm"}
*/

parser := fastjson.Parser{}
jsonValue, err := parser.Parse(request.Body)
parser := fastjson.Parser{}
jsonValue, err := parser.Parse(request.Body)

capsuleVersion, _ := hf.MemoryGet("capsule_version")
hf.Log("🖐 Version: " + capsuleVersion)
capsuleVersion, _ := hf.MemoryGet("capsule_version")
hf.Log("🖐 Version: " + capsuleVersion)

hf.Log("📝 Body: " + request.Body)
hf.Log("📝 URI: " + request.Uri)
hf.Log("📝 Method: " + request.Method)
hf.Log("📝 Body: " + request.Body)
hf.Log("📝 URI: " + request.Uri)
hf.Log("📝 Method: " + request.Method)

author := string(jsonValue.GetStringBytes("author"))
message := string(jsonValue.GetStringBytes("message"))
author := string(jsonValue.GetStringBytes("author"))
message := string(jsonValue.GetStringBytes("message"))

//author := gjson.Get(request.Body, "author")
//message := gjson.Get(request.Body, "message")
hf.Log("👋 " + message + " by " + author + " 😄")
//author := gjson.Get(request.Body, "author")
//message := gjson.Get(request.Body, "message")
hf.Log("👋 " + message + " by " + author + " 😄")

hf.Log("Content-Type: " + request.Headers["Content-Type"])
hf.Log("Content-Length: " + request.Headers["Content-Length"])
hf.Log("User-Agent: " + request.Headers["User-Agent"])
hf.Log("Content-Type: " + request.Headers["Content-Type"])
hf.Log("Content-Length: " + request.Headers["Content-Length"])
hf.Log("User-Agent: " + request.Headers["User-Agent"])

envMessage, err := hf.GetEnv("MESSAGE")
if err != nil {
hf.Log("😡 " + err.Error())
} else {
hf.Log("Environment variable: " + envMessage)
}
envMessage, err := hf.GetEnv("MESSAGE")
if err != nil {
hf.Log("😡 " + err.Error())
} else {
hf.Log("Environment variable: " + envMessage)
}

headersResp := map[string]string{
"Content-Type": "application/json; charset=utf-8",
"Message": "👋 hello world 🌍",
}
headersResp := map[string]string{
"Content-Type": "application/json; charset=utf-8",
"Message": "👋 hello world 🌍",
}

jsondoc := `{"message": "👋 hey! What's up?", "author": "Bob"}`
jsondoc := `{"message": "👋 hey! What's up?", "author": "Bob"}`

return hf.Response{Body: jsondoc, Headers: headersResp}, err
return hf.Response{Body: jsondoc, Headers: headersResp}, err
}

/*
Expand Down
2 changes: 2 additions & 0 deletions wasm_modules/capsule-hello-post/stress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hey -n 300 -c 100 -m POST \
# Requests/sec: 123.6958 wasi_snapshot_preview1.MustInstantiate(ctx, wasmRuntime)
# Requests/sec: 84.0781 deps: updates wazero to 1.0.0-pre.4
# Requests/sec: 167.1686 deps: updates wazero to 1.0.0-pre.9
# Requests/sec: 120.3790 deps: updates wazero to 1.0.1
# Requests/sec: 237.3747 deps: updates wazero to 1.0.2

0 comments on commit 49c66ed

Please sign in to comment.