From 5d4510fa0b2163bc256e0da3c19030c140f4a4f1 Mon Sep 17 00:00:00 2001 From: k33g Date: Sat, 24 Jun 2023 09:50:23 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9B=9F=20Updated:=20update=20HDK=20ve?= =?UTF-8?q?rsion=20number=20(0.0.5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- capsule-cli/go.mod | 2 +- capsule-http/go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/capsule-cli/go.mod b/capsule-cli/go.mod index d3959bf..8b821d0 100644 --- a/capsule-cli/go.mod +++ b/capsule-cli/go.mod @@ -5,7 +5,7 @@ go 1.20 require github.com/tetratelabs/wazero v1.1.0 // indirect require ( - github.com/bots-garden/capsule-host-sdk v0.0.4 + github.com/bots-garden/capsule-host-sdk v0.0.5 github.com/gofiber/fiber/v2 v2.44.0 ) diff --git a/capsule-http/go.mod b/capsule-http/go.mod index 4c15a5b..69e9fe9 100644 --- a/capsule-http/go.mod +++ b/capsule-http/go.mod @@ -16,7 +16,7 @@ require ( ) require ( - github.com/bots-garden/capsule-host-sdk v0.0.4 + github.com/bots-garden/capsule-host-sdk v0.0.5 github.com/gofiber/fiber/v2 v2.45.0 github.com/tetratelabs/wazero v1.2.0 golang.ngrok.com/ngrok v1.0.0 From 12e153184630bcfd0fa9e08deba5eee404b50091 Mon Sep 17 00:00:00 2001 From: k33g Date: Sat, 24 Jun 2023 10:44:25 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=9A=A7=20Work=20in=20progress:=20work?= =?UTF-8?q?ing=20on=20the=20integration=20tests=20of=20the=20FaaS=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- capsule-http/tests/.gitignore | 0 capsule-http/tests/faas/.gitignore | 2 + capsule-http/tests/faas/Taskfile.yml | 108 ++++++++++++++++-- .../tests/faas/functions/html-page/go.mod | 9 ++ .../tests/faas/functions/html-page/go.sum | 2 + .../tests/faas/functions/html-page/main.go | 21 ++++ .../tests/faas/functions/index-page/README.md | 2 + .../tests/faas/functions/index-page/go.mod | 6 +- .../tests/faas/functions/index-page/go.sum | 2 + .../faas/functions/index-page/index.html | 24 ++++ .../tests/faas/functions/index-page/main.go | 12 +- go.work | 1 + 12 files changed, 173 insertions(+), 16 deletions(-) create mode 100644 capsule-http/tests/.gitignore create mode 100644 capsule-http/tests/faas/functions/html-page/go.mod create mode 100644 capsule-http/tests/faas/functions/html-page/go.sum create mode 100644 capsule-http/tests/faas/functions/html-page/main.go create mode 100644 capsule-http/tests/faas/functions/index-page/README.md create mode 100644 capsule-http/tests/faas/functions/index-page/index.html diff --git a/capsule-http/tests/.gitignore b/capsule-http/tests/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/capsule-http/tests/faas/.gitignore b/capsule-http/tests/faas/.gitignore index 35d3396..ded271a 100644 --- a/capsule-http/tests/faas/.gitignore +++ b/capsule-http/tests/faas/.gitignore @@ -1,2 +1,4 @@ tmp/*.wasm +*.wasm + diff --git a/capsule-http/tests/faas/Taskfile.yml b/capsule-http/tests/faas/Taskfile.yml index bf639ea..64c8b93 100644 --- a/capsule-http/tests/faas/Taskfile.yml +++ b/capsule-http/tests/faas/Taskfile.yml @@ -1,5 +1,8 @@ version: '3' +description: > + # Integration tests of the FaaS mode of Capsule + tasks: # Build of capsule-http @@ -14,6 +17,100 @@ tasks: sudo cp capsule-http /usr/local/bin/capsule-http capsule-http --version + build-capsule-http: + description: > + Build capsule-http, and copy the binary to the current directory + `/capsule/capsule-http/tests/faas` + cmds: + - | + echo "📦 Building capsule-http..." + cd ../.. + pwd + go build -ldflags="-s -w" -o capsule-http + ls -lh capsule-http + mv capsule-http ./tests/faas + cd ./tests/faas + ./capsule-http --version + + build-html-page: + cmds: + - | + cd functions/html-page + tinygo build -o html-page.wasm \ + -scheduler=none \ + --no-debug \ + -target wasi ./main.go + ls -lh *.wasm + mv html-page.wasm ../.. + + build-index-page: + description: > + In "FaaS mode", if an `index.page.wasm` file exists + Capsule will serve it with the "/" route + Otherwise, Capsule will return a simple message with its version number + cmds: + - | + cd functions/index-page + tinygo build -o index.page.wasm \ + -scheduler=none \ + --no-debug \ + -target wasi ./main.go + ls -lh *.wasm + mv index.page.wasm ../.. + + # Start main capsule process + start-capsule-http-with-file: + description: > + Start Capsule HTTP with an wasm module. + Capsule will load and serve this wasm module, + but in the same process. It means that if you want to update the `index.page.wasm` module, + you will need to stop and start again the Capsule HTTP process. + + There is another solution: + - start the capsule http without any file + - start a function name `index.page` (as any other function) + Then, you will be able to redeploy a version of `index.page` + + See these task: `start-capsule-http` and `start-index` + env: + HTTP_PORT: '8080' + #WASM_FILE: './functions/index-page/index.page.wasm' + WASM_FILE: './html-page.wasm' + CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" + cmds: + - | # use --faas=true to activate the faas mode of Capsule HTTP + #capsule-http --wasm=${WASM_FILE} --httpPort=${HTTP_PORT} --faas=true + ./capsule-http --wasm=${WASM_FILE} --httpPort=${HTTP_PORT} --faas=true + # you can use http://capsule-ide.local:8080/ + + start-capsule-http: + env: + HTTP_PORT: '8080' + CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" + cmds: + - | # use --faas=true to activate the faas mode of Capsule HTTP + ./capsule-http --httpPort=${HTTP_PORT} --faas=true + # you can use http://capsule-ide.local:8080/ + + start-index: + env: + CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" + CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" + cmds: + - | + capsctl \ + --cmd=start \ + --name=index.page \ + --revision=default \ + --wasm=./index.page.wasm + + todo: > + - redeploy of index + + # ======================================= + # Without capsctl, only the API + # ======================================= + build-hello-functions: cmds: - | # hello-default @@ -105,16 +202,7 @@ tasks: "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - # Start main capsule process - start-capsule-http: - env: - HTTP_PORT: '8080' - WASM_FILE: './functions/index-page/index-page.wasm' - CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" - cmds: - - | # use --faas=true to activate the faas mode of Capsule HTTP - capsule-http --wasm=${WASM_FILE} --httpPort=${HTTP_PORT} --faas=true - # you can use http://capsule-ide.local:8080/ + launch-hello-functions: cmds: diff --git a/capsule-http/tests/faas/functions/html-page/go.mod b/capsule-http/tests/faas/functions/html-page/go.mod new file mode 100644 index 0000000..f5ae612 --- /dev/null +++ b/capsule-http/tests/faas/functions/html-page/go.mod @@ -0,0 +1,9 @@ +module index-page + +go 1.20 + +require github.com/bots-garden/capsule-module-sdk v0.0.4 + +require github.com/valyala/fastjson v1.6.4 // indirect + +replace github.com/bots-garden/capsule-module-sdk => ../../../../../../capsule-module-sdk diff --git a/capsule-http/tests/faas/functions/html-page/go.sum b/capsule-http/tests/faas/functions/html-page/go.sum new file mode 100644 index 0000000..d0e4603 --- /dev/null +++ b/capsule-http/tests/faas/functions/html-page/go.sum @@ -0,0 +1,2 @@ +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= diff --git a/capsule-http/tests/faas/functions/html-page/main.go b/capsule-http/tests/faas/functions/html-page/main.go new file mode 100644 index 0000000..f1b7cde --- /dev/null +++ b/capsule-http/tests/faas/functions/html-page/main.go @@ -0,0 +1,21 @@ +// Package main +package main + +import ( + capsule "github.com/bots-garden/capsule-module-sdk" +) + +func main() { + capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) { + + return capsule.HTTPResponse{ + TextBody: "

👋 Hello World! 🌍

", + Headers: `{ + "Content-Type": "text/html; charset=utf-8", + "Cache-Control": "no-cache", + "X-Powered-By": "capsule-module-sdk" + }`, + StatusCode: 200, + }, nil + }) +} diff --git a/capsule-http/tests/faas/functions/index-page/README.md b/capsule-http/tests/faas/functions/index-page/README.md new file mode 100644 index 0000000..e9c7f13 --- /dev/null +++ b/capsule-http/tests/faas/functions/index-page/README.md @@ -0,0 +1,2 @@ + # Chronicles reborn + \ No newline at end of file diff --git a/capsule-http/tests/faas/functions/index-page/go.mod b/capsule-http/tests/faas/functions/index-page/go.mod index f5ae612..75e8e62 100644 --- a/capsule-http/tests/faas/functions/index-page/go.mod +++ b/capsule-http/tests/faas/functions/index-page/go.mod @@ -1,9 +1,7 @@ -module index-page +module index.page go 1.20 -require github.com/bots-garden/capsule-module-sdk v0.0.4 +require github.com/bots-garden/capsule-module-sdk v0.0.3 require github.com/valyala/fastjson v1.6.4 // indirect - -replace github.com/bots-garden/capsule-module-sdk => ../../../../../../capsule-module-sdk diff --git a/capsule-http/tests/faas/functions/index-page/go.sum b/capsule-http/tests/faas/functions/index-page/go.sum index d0e4603..a96e182 100644 --- a/capsule-http/tests/faas/functions/index-page/go.sum +++ b/capsule-http/tests/faas/functions/index-page/go.sum @@ -1,2 +1,4 @@ +github.com/bots-garden/capsule-module-sdk v0.0.3 h1:a0TRgwdiJjc+9raOe4zQoWPnzxKegqmInVmwzlaDuug= +github.com/bots-garden/capsule-module-sdk v0.0.3/go.mod h1:DtKYwanz4YvBwSpu0GuuhtkeFE6+jDgEucBOTWVBMy8= github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= diff --git a/capsule-http/tests/faas/functions/index-page/index.html b/capsule-http/tests/faas/functions/index-page/index.html new file mode 100644 index 0000000..7a8bdd7 --- /dev/null +++ b/capsule-http/tests/faas/functions/index-page/index.html @@ -0,0 +1,24 @@ + + + + Wasm is fantastic 😍 + + + + + +
+
+

👋 Hello World 🌍

+

Served with 💜 by Capsule 💊

+

[🚀 Faas mode]

+
+
+ + + diff --git a/capsule-http/tests/faas/functions/index-page/main.go b/capsule-http/tests/faas/functions/index-page/main.go index f1b7cde..49ef93a 100644 --- a/capsule-http/tests/faas/functions/index-page/main.go +++ b/capsule-http/tests/faas/functions/index-page/main.go @@ -1,15 +1,22 @@ -// Package main +// Package main => serving an html resource package main import ( + _ "embed" capsule "github.com/bots-garden/capsule-module-sdk" ) +var ( + //go:embed index.html + html []byte +) + func main() { + capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) { return capsule.HTTPResponse{ - TextBody: "

👋 Hello World! 🌍

", + TextBody: string(html), Headers: `{ "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-cache", @@ -19,3 +26,4 @@ func main() { }, nil }) } +//TODO: make something easier for the headers (see old version of Capsule) \ No newline at end of file diff --git a/go.work b/go.work index f84077f..bc53cdf 100644 --- a/go.work +++ b/go.work @@ -18,5 +18,6 @@ use ( ./capsule-http/tests/faas/functions/hello-green ./capsule-http/tests/faas/functions/hello-orange ./capsule-http/tests/faas/functions/index-page + ./capsule-http/tests/faas/functions/html-page ) From 8a919333389110029bacc7de0d4c01f05f829891 Mon Sep 17 00:00:00 2001 From: k33g Date: Sun, 25 Jun 2023 07:45:44 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=92=BE=20Saved.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- capsctl/description.txt | 2 +- capsule-cli/description.txt | 2 +- capsule-http/Taskfile.yml | 2 +- .../capsule.http.stress.report.0.4.0.txt | 56 +-- .../capsule_xp.http.stress.report.0.4.0.txt | 46 -- capsule-http/tests/faas/.gitignore | 2 + capsule-http/tests/faas/BuildTasks.yml | 80 ++++ capsule-http/tests/faas/CallTasks.yml | 44 ++ capsule-http/tests/faas/DropTasks.yml | 51 +++ capsule-http/tests/faas/DuplicateTasks.yml | 29 ++ capsule-http/tests/faas/PublishTasks.yml | 58 +++ capsule-http/tests/faas/README.md | 21 +- capsule-http/tests/faas/StartTasks.yml | 64 +++ capsule-http/tests/faas/StressTasks.yml | 20 + capsule-http/tests/faas/Taskfile.yml | 412 ++---------------- capsule-http/tests/faas/draft.api.yml | 264 +++++++++++ capsule-http/tools/description.txt | 2 +- docs/capsule-http-faas-mode.md | 6 +- docs/capsule-http-flags.md | 1 + docs/capsule-http-install-pi.md | 4 +- docs/capsule-http-ovh-deploy.md | 2 + docs/docker-capsule-http.md | 10 +- docs/getting-started-cli.md | 2 +- docs/getting-started-http-ngrok.md | 2 +- docs/getting-started-http.md | 103 ++++- docs/index.md | 2 +- mkdocs.yml | 1 + release/README.md | 3 +- 28 files changed, 801 insertions(+), 490 deletions(-) delete mode 100644 capsule-http/capsule_xp.http.stress.report.0.4.0.txt create mode 100644 capsule-http/tests/faas/BuildTasks.yml create mode 100644 capsule-http/tests/faas/CallTasks.yml create mode 100644 capsule-http/tests/faas/DropTasks.yml create mode 100644 capsule-http/tests/faas/DuplicateTasks.yml create mode 100644 capsule-http/tests/faas/PublishTasks.yml create mode 100644 capsule-http/tests/faas/StartTasks.yml create mode 100644 capsule-http/tests/faas/StressTasks.yml create mode 100644 capsule-http/tests/faas/draft.api.yml create mode 100644 docs/capsule-http-ovh-deploy.md diff --git a/capsctl/description.txt b/capsctl/description.txt index 1ed7c15..e82172d 100644 --- a/capsctl/description.txt +++ b/capsctl/description.txt @@ -1 +1 @@ -CapsCtl v0.3.9 🥒 [cucumber] \ No newline at end of file +CapsCtl v0.4.0 🌶️ [chili pepper] \ No newline at end of file diff --git a/capsule-cli/description.txt b/capsule-cli/description.txt index 5c427d0..f79ddab 100644 --- a/capsule-cli/description.txt +++ b/capsule-cli/description.txt @@ -1 +1 @@ -[CLI] v0.3.9 🥒 [cucumber] \ No newline at end of file +[CLI] v0.4.0 🌶️ [chili pepper] diff --git a/capsule-http/Taskfile.yml b/capsule-http/Taskfile.yml index 86c2d3a..0cb801e 100644 --- a/capsule-http/Taskfile.yml +++ b/capsule-http/Taskfile.yml @@ -348,7 +348,7 @@ tasks: - | hey -n 300 -c 100 -m POST \ -H "Content-Type: application/json; charset=utf-8" \ - -d "${JSON_DATA}" ${PROTOCOL}://${DOMAIN}:${HTTP_PORT} > capsule_xp.http.stress.report.0.4.0.txt + -d "${JSON_DATA}" ${PROTOCOL}://${DOMAIN}:${HTTP_PORT} > capsule.http.stress.report.0.4.0.txt #- killport ${HTTP_PORT} build-hey: diff --git a/capsule-http/capsule.http.stress.report.0.4.0.txt b/capsule-http/capsule.http.stress.report.0.4.0.txt index 09cd8e6..084f4f9 100644 --- a/capsule-http/capsule.http.stress.report.0.4.0.txt +++ b/capsule-http/capsule.http.stress.report.0.4.0.txt @@ -1,43 +1,43 @@ Summary: - Total: 0.1811 secs - Slowest: 0.1136 secs - Fastest: 0.0011 secs - Average: 0.0468 secs - Requests/sec: 1656.8637 + Total: 0.1022 secs + Slowest: 0.0604 secs + Fastest: 0.0037 secs + Average: 0.0283 secs + Requests/sec: 2934.1867 Total data: 15900 bytes Size/request: 53 bytes Response time histogram: - 0.001 [1] |■ - 0.012 [53] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ - 0.024 [18] |■■■■■■■■■■■■■ - 0.035 [30] |■■■■■■■■■■■■■■■■■■■■■ - 0.046 [45] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ - 0.057 [23] |■■■■■■■■■■■■■■■■ - 0.069 [57] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ - 0.080 [28] |■■■■■■■■■■■■■■■■■■■■ - 0.091 [27] |■■■■■■■■■■■■■■■■■■■ - 0.102 [14] |■■■■■■■■■■ - 0.114 [4] |■■■ + 0.004 [1] |■ + 0.009 [14] |■■■■■■■■ + 0.015 [32] |■■■■■■■■■■■■■■■■■■■ + 0.021 [60] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ + 0.026 [51] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ + 0.032 [16] |■■■■■■■■■ + 0.038 [69] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ + 0.043 [11] |■■■■■■ + 0.049 [14] |■■■■■■■■ + 0.055 [11] |■■■■■■ + 0.060 [21] |■■■■■■■■■■■■ Latency distribution: - 10% in 0.0022 secs - 25% in 0.0243 secs - 50% in 0.0488 secs - 75% in 0.0675 secs - 90% in 0.0848 secs - 95% in 0.0920 secs - 99% in 0.1041 secs + 10% in 0.0111 secs + 25% in 0.0191 secs + 50% in 0.0254 secs + 75% in 0.0366 secs + 90% in 0.0500 secs + 95% in 0.0557 secs + 99% in 0.0603 secs Details (average, fastest, slowest): - DNS+dialup: 0.0024 secs, 0.0011 secs, 0.1136 secs - DNS-lookup: 0.0020 secs, 0.0000 secs, 0.0188 secs - req write: 0.0003 secs, 0.0000 secs, 0.0029 secs - resp wait: 0.0440 secs, 0.0011 secs, 0.1136 secs - resp read: 0.0001 secs, 0.0000 secs, 0.0023 secs + DNS+dialup: 0.0043 secs, 0.0037 secs, 0.0604 secs + DNS-lookup: 0.0069 secs, 0.0000 secs, 0.0267 secs + req write: 0.0003 secs, 0.0000 secs, 0.0082 secs + resp wait: 0.0196 secs, 0.0003 secs, 0.0341 secs + resp read: 0.0002 secs, 0.0000 secs, 0.0136 secs Status code distribution: [200] 300 responses diff --git a/capsule-http/capsule_xp.http.stress.report.0.4.0.txt b/capsule-http/capsule_xp.http.stress.report.0.4.0.txt deleted file mode 100644 index af4d040..0000000 --- a/capsule-http/capsule_xp.http.stress.report.0.4.0.txt +++ /dev/null @@ -1,46 +0,0 @@ - -Summary: - Total: 0.1024 secs - Slowest: 0.0554 secs - Fastest: 0.0004 secs - Average: 0.0276 secs - Requests/sec: 2930.3377 - - Total data: 15900 bytes - Size/request: 53 bytes - -Response time histogram: - 0.000 [1] | - 0.006 [3] |■ - 0.011 [20] |■■■■■■■■ - 0.017 [20] |■■■■■■■■ - 0.022 [47] |■■■■■■■■■■■■■■■■■■ - 0.028 [102] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ - 0.033 [41] |■■■■■■■■■■■■■■■■ - 0.039 [11] |■■■■ - 0.044 [7] |■■■ - 0.050 [26] |■■■■■■■■■■ - 0.055 [22] |■■■■■■■■■ - - -Latency distribution: - 10% in 0.0129 secs - 25% in 0.0199 secs - 50% in 0.0260 secs - 75% in 0.0320 secs - 90% in 0.0469 secs - 95% in 0.0515 secs - 99% in 0.0548 secs - -Details (average, fastest, slowest): - DNS+dialup: 0.0016 secs, 0.0004 secs, 0.0554 secs - DNS-lookup: 0.0027 secs, 0.0000 secs, 0.0224 secs - req write: 0.0008 secs, 0.0000 secs, 0.0232 secs - resp wait: 0.0214 secs, 0.0003 secs, 0.0451 secs - resp read: 0.0019 secs, 0.0000 secs, 0.0237 secs - -Status code distribution: - [200] 300 responses - - - diff --git a/capsule-http/tests/faas/.gitignore b/capsule-http/tests/faas/.gitignore index ded271a..77f8c61 100644 --- a/capsule-http/tests/faas/.gitignore +++ b/capsule-http/tests/faas/.gitignore @@ -1,4 +1,6 @@ tmp/*.wasm *.wasm +capsctl +capsule-http diff --git a/capsule-http/tests/faas/BuildTasks.yml b/capsule-http/tests/faas/BuildTasks.yml new file mode 100644 index 0000000..efdf972 --- /dev/null +++ b/capsule-http/tests/faas/BuildTasks.yml @@ -0,0 +1,80 @@ +version: '3' + +tasks: + + hello-functions: + cmds: + - | # hello-default + cd functions/hello-default + tinygo build -o hello-default.wasm \ + -scheduler=none \ + --no-debug \ + -target wasi ./main.go + ls -lh *.wasm + mv hello-default.wasm ../.. + - | # hello-blue + cd functions/hello-blue + tinygo build -o hello-blue.wasm \ + -scheduler=none \ + --no-debug \ + -target wasi ./main.go + ls -lh *.wasm + mv hello-blue.wasm ../.. + - | # hello-green + cd functions/hello-green + tinygo build -o hello-green.wasm \ + -scheduler=none \ + --no-debug \ + -target wasi ./main.go + ls -lh *.wasm + mv hello-green.wasm ../.. + - | # hello-orange + cd functions/hello-orange + tinygo build -o hello-orange.wasm \ + -scheduler=none \ + --no-debug \ + -target wasi ./main.go + ls -lh *.wasm + mv hello-orange.wasm ../.. + + capsctl: + description: > + Build capsctl, and copy the binary to the current directory + `/capsule/capsule-http/tests/faas` + cmds: + - | + echo "📦 Building capsctl..." + cd ../../../capsctl + pwd + go build -ldflags="-s -w" -o capsctl + ls -lh capsctl + mv capsctl ../capsule-http/tests/faas + cd ../capsule-http/tests/faas + ./capsctl --version + + capsule-http: + description: > + Build capsule-http, and copy the binary to the current directory + `/capsule/capsule-http/tests/faas` + cmds: + - | + echo "📦 Building capsule-http..." + cd ../.. + pwd + go build -ldflags="-s -w" -o capsule-http + ls -lh capsule-http + mv capsule-http ./tests/faas + cd ./tests/faas + ./capsule-http --version + + # Build of capsule-http + install-capsule-http: + cmds: + - | + echo "📦 Building capsule-http..." + cd ../.. + pwd + go build -ldflags="-s -w" -o capsule-http + ls -lh capsule-http + sudo cp capsule-http /usr/local/bin/capsule-http + capsule-http --version diff --git a/capsule-http/tests/faas/CallTasks.yml b/capsule-http/tests/faas/CallTasks.yml new file mode 100644 index 0000000..8223c77 --- /dev/null +++ b/capsule-http/tests/faas/CallTasks.yml @@ -0,0 +1,44 @@ +version: '3' + +env: + CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" + CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" + +tasks: + + orange: + cmds: + - | + curl -X POST ${CAPSULE_MAIN_PROCESS_URL}/functions/hello/orange \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d 'Bob Morane' + + orange_two: + cmds: + - | + curl -X POST ${CAPSULE_MAIN_PROCESS_URL}/functions/hello/orange_two \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d 'Bob Morane' + + green: + cmds: + - | + curl -X POST ${CAPSULE_MAIN_PROCESS_URL}/functions/hello/green \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d 'Bob Morane' + + blue: + cmds: + - | + curl -X POST ${CAPSULE_MAIN_PROCESS_URL}/functions/hello/blue \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d 'Bob Morane' + + default: + description: > + The `default` revision can be call without specifying `default` into the route + cmds: + - | + curl -X POST ${CAPSULE_MAIN_PROCESS_URL}/functions/hello \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d 'Bob Morane' \ No newline at end of file diff --git a/capsule-http/tests/faas/DropTasks.yml b/capsule-http/tests/faas/DropTasks.yml new file mode 100644 index 0000000..a3bd991 --- /dev/null +++ b/capsule-http/tests/faas/DropTasks.yml @@ -0,0 +1,51 @@ +version: '3' + +description: > + `CAPSULE_FAAS_TOKEN` and `CAPSULE_MAIN_PROCESS_URL` are required + to run `capsctl` + +env: + CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" + CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" + +tasks: + + orange: + cmds: + - | + ./capsctl \ + --cmd=drop \ + --name=hello \ + --revision=orange + + orange_two: + cmds: + - | + ./capsctl \ + --cmd=drop \ + --name=hello \ + --revision=orange_two + + green: + cmds: + - | + ./capsctl \ + --cmd=drop \ + --name=hello \ + --revision=green + + blue: + cmds: + - | + ./capsctl \ + --cmd=drop \ + --name=hello \ + --revision=blue + + default: + cmds: + - | + ./capsctl \ + --cmd=drop \ + --name=hello \ + --revision=default diff --git a/capsule-http/tests/faas/DuplicateTasks.yml b/capsule-http/tests/faas/DuplicateTasks.yml new file mode 100644 index 0000000..7ac859c --- /dev/null +++ b/capsule-http/tests/faas/DuplicateTasks.yml @@ -0,0 +1,29 @@ +version: '3' + +description: > + `CAPSULE_FAAS_TOKEN` and `CAPSULE_MAIN_PROCESS_URL` are required + to run `capsctl` + +env: + CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" + CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" + +tasks: + + orange: + cmds: + - | + ./capsctl \ + --cmd=duplicate \ + --name=hello \ + --revision=orange \ + --newRevision=orange_two + + orange_two: + cmds: + - | + ./capsctl \ + --cmd=duplicate \ + --name=hello \ + --revision=orange_two \ + --newRevision=orange diff --git a/capsule-http/tests/faas/PublishTasks.yml b/capsule-http/tests/faas/PublishTasks.yml new file mode 100644 index 0000000..60f1ba2 --- /dev/null +++ b/capsule-http/tests/faas/PublishTasks.yml @@ -0,0 +1,58 @@ +version: '3' + +tasks: + + hello-functions: + description: > + Publish all the hello functions to a GitLab registry + https://gitlab.com/wasmkitchen/wasm.registry/-/packages + env: + GITLAB_WASM_PROJECT_ID: "45020306" + WASM_PACKAGE: "capsule" + cmds: + - | + FUNCTION_NAME="hello" + WASM_VERSION="default" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + #cd functions/${FUNCTION_NAME}-${WASM_VERSION} + WASM_FILE="./${WASM_MODULE}" + echo "📦 ${WASM_PACKAGE}" + echo "📝 ${WASM_MODULE} ${WASM_VERSION}" + curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ + --upload-file ${WASM_FILE} \ + "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + - | + FUNCTION_NAME="hello" + WASM_VERSION="blue" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + #cd functions/${FUNCTION_NAME}-${WASM_VERSION} + WASM_FILE="./${WASM_MODULE}" + echo "📦 ${WASM_PACKAGE}" + echo "📝 ${WASM_MODULE} ${WASM_VERSION}" + curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ + --upload-file ${WASM_FILE} \ + "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + - | + FUNCTION_NAME="hello" + WASM_VERSION="green" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + #cd functions/${FUNCTION_NAME}-${WASM_VERSION} + WASM_FILE="./${WASM_MODULE}" + echo "📦 ${WASM_PACKAGE}" + echo "📝 ${WASM_MODULE} ${WASM_VERSION}" + curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ + --upload-file ${WASM_FILE} \ + "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + - | + FUNCTION_NAME="hello" + WASM_VERSION="orange" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + #cd functions/${FUNCTION_NAME}-${WASM_VERSION} + WASM_FILE="./${WASM_MODULE}" + echo "📦 ${WASM_PACKAGE}" + echo "📝 ${WASM_MODULE} ${WASM_VERSION}" + curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ + --upload-file ${WASM_FILE} \ + "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + + diff --git a/capsule-http/tests/faas/README.md b/capsule-http/tests/faas/README.md index 3a55fda..8f82867 100644 --- a/capsule-http/tests/faas/README.md +++ b/capsule-http/tests/faas/README.md @@ -3,23 +3,6 @@ > - current operation could be subject to change ```bash -task build-and-install-capsule-http -task build-hello-functions +# 🚧 work in progress +``` -task build-and-install-capsule-http build-hello-functions - -task start-capsule-http -task launch-hello-functions - -task call-hello-functions - -task kill-hello-default-process -task kill-hello-blue-process -task kill-hello-green-process -task kill-hello-orange-process - -task stress-average-hello -task stress-high-hello - -task processes-list -``` \ No newline at end of file diff --git a/capsule-http/tests/faas/StartTasks.yml b/capsule-http/tests/faas/StartTasks.yml new file mode 100644 index 0000000..7300cad --- /dev/null +++ b/capsule-http/tests/faas/StartTasks.yml @@ -0,0 +1,64 @@ +version: '3' + +description: > + `CAPSULE_FAAS_TOKEN` and `CAPSULE_MAIN_PROCESS_URL` are required + to run `capsctl` + +env: + CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" + CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" + +tasks: + + orange: + cmds: + - | + ./capsctl \ + --cmd=start \ + --name=hello \ + --revision=orange \ + --description="hello orange deployment" \ + --env='["MESSAGE=🍊","GREETING=🎉"]'\ + --wasm=./hello-orange.wasm + remarks: > + `--path`: allow to set the path to `capsule-http` + example: `--path=/home/ubuntu/capsule-http` + otherwise, the default value is used (the current path process) + + green: + cmds: + - | + ./capsctl \ + --cmd=start \ + --name=hello \ + --revision=green \ + --stopAfter=10 \ + --env='["MESSAGE=🍏","GREETING=🎉"]'\ + --description="hello green deployment" \ + --wasm=./hello-green.wasm + remarks: > + `--stopAfter=10`: stop the function after 10 seconds + + blue: + cmds: + - | + ./capsctl \ + --cmd=start \ + --name=hello \ + --revision=blue \ + --stopAfter=10 \ + --env='["MESSAGE=🦋","GREETING=🎉"]'\ + --description="hello blue deployment" \ + --wasm=./hello-blue.wasm + + default: + cmds: + - | + ./capsctl \ + --cmd=start \ + --name=hello \ + --revision=default \ + --stopAfter=10 \ + --env='["MESSAGE=🐼","GREETING=🚀"]'\ + --description="hello default deployment" \ + --wasm=./hello-default.wasm diff --git a/capsule-http/tests/faas/StressTasks.yml b/capsule-http/tests/faas/StressTasks.yml new file mode 100644 index 0000000..f78a359 --- /dev/null +++ b/capsule-http/tests/faas/StressTasks.yml @@ -0,0 +1,20 @@ +version: '3' + +env: + CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" + +tasks: + + orange: + cmds: + - | + hey -n 300 -c 100 -m POST \ + -H "Content-Type: text/plain; charset=utf-8" \ + -d "Bob Morane" ${CAPSULE_MAIN_PROCESS_URL}/functions/hello/orange + + green: + cmds: + - | + hey -n 300 -c 100 -m POST \ + -H "Content-Type: text/plain; charset=utf-8" \ + -d "Bob Morane" ${CAPSULE_MAIN_PROCESS_URL}/functions/hello/green diff --git a/capsule-http/tests/faas/Taskfile.yml b/capsule-http/tests/faas/Taskfile.yml index 64c8b93..34d0efe 100644 --- a/capsule-http/tests/faas/Taskfile.yml +++ b/capsule-http/tests/faas/Taskfile.yml @@ -3,35 +3,29 @@ version: '3' description: > # Integration tests of the FaaS mode of Capsule -tasks: + ## Build all hello functions + + ```bash + task build:hello-functions + ``` + ## Publish all hello functions to a GitLab registry + + > requirement: you have to build the functionns first + ```bash + task publish:hello-functions + ``` + +includes: + build: ./BuildTasks.yml + publish: ./PublishTasks.yml + start: ./StartTasks.yml + call: ./CallTasks.yml + drop: ./DropTasks.yml + duplicate: ./DuplicateTasks.yml + stress: ./StressTasks.yml - # Build of capsule-http - build-and-install-capsule-http: - cmds: - - | - echo "📦 Building capsule-http..." - cd ../.. - pwd - go build -ldflags="-s -w" -o capsule-http - ls -lh capsule-http - sudo cp capsule-http /usr/local/bin/capsule-http - capsule-http --version +tasks: - build-capsule-http: - description: > - Build capsule-http, and copy the binary to the current directory - `/capsule/capsule-http/tests/faas` - cmds: - - | - echo "📦 Building capsule-http..." - cd ../.. - pwd - go build -ldflags="-s -w" -o capsule-http - ls -lh capsule-http - mv capsule-http ./tests/faas - cd ./tests/faas - ./capsule-http --version - build-html-page: cmds: - | @@ -61,7 +55,7 @@ tasks: # Start main capsule process start-capsule-http-with-file: description: > - Start Capsule HTTP with an wasm module. + Start Capsule HTTP (in Faas mode) with an wasm module. Capsule will load and serve this wasm module, but in the same process. It means that if you want to update the `index.page.wasm` module, you will need to stop and start again the Capsule HTTP process. @@ -84,6 +78,10 @@ tasks: # you can use http://capsule-ide.local:8080/ start-capsule-http: + description: > + Start Capsule HTTP (in Faas mode) without specifying a wasm module. + Then, with the "/" route, Capsule HTTP will serve the `index.page` function + when it will be available. env: HTTP_PORT: '8080' CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" @@ -93,365 +91,20 @@ tasks: # you can use http://capsule-ide.local:8080/ start-index: + description: > + Start the `index.page` function env: CAPSULE_FAAS_TOKEN: "ILOVEPANDAS" - CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" + #CAPSULE_MAIN_PROCESS_URL: "http://capsule-ide.local:8080" cmds: - | - capsctl \ + ./capsctl \ --cmd=start \ --name=index.page \ --revision=default \ --wasm=./index.page.wasm - todo: > - - redeploy of index - - # ======================================= - # Without capsctl, only the API - # ======================================= - - build-hello-functions: - cmds: - - | # hello-default - cd functions/hello-default - tinygo build -o hello-default.wasm \ - -scheduler=none \ - --no-debug \ - -target wasi ./main.go - ls -lh *.wasm - - | # hello-blue - cd functions/hello-blue - tinygo build -o hello-blue.wasm \ - -scheduler=none \ - --no-debug \ - -target wasi ./main.go - ls -lh *.wasm - - | # hello-green - cd functions/hello-green - tinygo build -o hello-green.wasm \ - -scheduler=none \ - --no-debug \ - -target wasi ./main.go - ls -lh *.wasm - - | # hello-orange - cd functions/hello-orange - tinygo build -o hello-orange.wasm -llvm-features "+bulk-memory" \ - -scheduler=none \ - --no-debug \ - -target wasi ./main.go - ls -lh *.wasm - - | # index-page - cd functions/index-page - tinygo build -o index-page.wasm \ - -scheduler=none \ - --no-debug \ - -target wasi ./main.go - ls -lh *.wasm - - publish-hello-functions-to-gitlab: - # GitLab registry - # https://gitlab.com/wasmkitchen/wasm.registry/-/packages - env: - GITLAB_WASM_PROJECT_ID: "45020306" - WASM_PACKAGE: "capsule" - cmds: - - | - FUNCTION_NAME="hello" - WASM_VERSION="default" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - cd functions/${FUNCTION_NAME}-${WASM_VERSION} - WASM_FILE="./${WASM_MODULE}" - echo "📦 ${WASM_PACKAGE}" - echo "📝 ${WASM_MODULE} ${WASM_VERSION}" - curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ - --upload-file ${WASM_FILE} \ - "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - | - FUNCTION_NAME="hello" - WASM_VERSION="blue" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - cd functions/${FUNCTION_NAME}-${WASM_VERSION} - WASM_FILE="./${WASM_MODULE}" - echo "📦 ${WASM_PACKAGE}" - echo "📝 ${WASM_MODULE} ${WASM_VERSION}" - curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ - --upload-file ${WASM_FILE} \ - "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - | - FUNCTION_NAME="hello" - WASM_VERSION="green" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - cd functions/${FUNCTION_NAME}-${WASM_VERSION} - WASM_FILE="./${WASM_MODULE}" - echo "📦 ${WASM_PACKAGE}" - echo "📝 ${WASM_MODULE} ${WASM_VERSION}" - curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ - --upload-file ${WASM_FILE} \ - "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - | - FUNCTION_NAME="hello" - WASM_VERSION="orange" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - cd functions/${FUNCTION_NAME}-${WASM_VERSION} - WASM_FILE="./${WASM_MODULE}" - echo "📦 ${WASM_PACKAGE}" - echo "📝 ${WASM_MODULE} ${WASM_VERSION}" - curl --header "PRIVATE-TOKEN: ${GITLAB_WASM_TOKEN}" \ - --upload-file ${WASM_FILE} \ - "https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - - - - launch-hello-functions: - cmds: - - | - FUNCTION_NAME="hello" - FUNCTION_REVISION="default" - WASM_FILE="./functions/hello-default/hello-default.wasm" - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${FUNCTION_REVISION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}"], - "env": [] - } - EOF - - | # 👋 the hello blue function stops after 30 seconds - FUNCTION_NAME="hello" - FUNCTION_REVISION="blue" - WASM_FILE="./functions/hello-blue/hello-blue.wasm" - DURATION=30 - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${FUNCTION_REVISION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}", "-stopAfter=${DURATION}"], - "env": [] - } - EOF - - | - FUNCTION_NAME="hello" - FUNCTION_REVISION="green" - WASM_FILE="./functions/hello-green/hello-green.wasm" - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${FUNCTION_REVISION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}"], - "env": [] - } - EOF - - | - FUNCTION_NAME="hello" - FUNCTION_REVISION="orange" - WASM_FILE="./functions/hello-orange/hello-orange.wasm" - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${FUNCTION_REVISION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}"], - "env": [] - } - EOF - - launch-remote-hello-functions: - env: - GITLAB_WASM_PROJECT_ID: "45020306" - WASM_PACKAGE: "capsule" - cmds: - - | - FUNCTION_NAME="hello" - WASM_VERSION="default" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - WASM_FILE="./tmp/${WASM_MODULE}" - DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${WASM_VERSION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}", "-url=${DOWNLOAD_URL}"], - "env": [] - } - EOF - - | # 👋 the hello blue function stops after 30 seconds - FUNCTION_NAME="hello" - WASM_VERSION="blue" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - WASM_FILE="./tmp/${WASM_MODULE}" - DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - DURATION=30 - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${WASM_VERSION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}", "-stopAfter=${DURATION}", "-url=${DOWNLOAD_URL}"], - "env": [] - } - EOF - - | - FUNCTION_NAME="hello" - WASM_VERSION="green" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - WASM_FILE="./tmp/${WASM_MODULE}" - DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${WASM_VERSION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}", "-url=${DOWNLOAD_URL}"], - "env": [] - } - EOF - - | - FUNCTION_NAME="hello" - WASM_VERSION="orange" - WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" - WASM_FILE="./tmp/${WASM_MODULE}" - DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" - - curl -X POST localhost:8080/functions/start \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d @- << EOF - { - "name":"${FUNCTION_NAME}", - "revision":"${WASM_VERSION}", - "description":"hello function", - "path":"/usr/local/bin/capsule-http", - "args": ["", "-wasm=${WASM_FILE}", "-url=${DOWNLOAD_URL}"], - "env": [] - } - EOF - - - call-hello-functions: - env: - DATA: 'Bob Morane' - HTTP_PORT: '8080' - DOMAIN: 'localhost' - PROTOCOL: 'http' - cmds: - - | - curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/default \ - -H 'Content-Type: text/plain; charset=utf-8' \ - -d "${DATA}" - echo "" - echo "" - - | - curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/blue \ - -H 'Content-Type: text/plain; charset=utf-8' \ - -d "${DATA}" - echo "" - echo "" - - | - curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/green \ - -H 'Content-Type: text/plain; charset=utf-8' \ - -d "${DATA}" - echo "" - echo "" - - | - curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/orange \ - -H 'Content-Type: text/plain; charset=utf-8' \ - -d "${DATA}" - echo "" - echo "" - - kill-hello-default-process: - env: - HTTP_PORT: '8080' - DOMAIN: 'localhost' - PROTOCOL: 'http' - cmds: - - | - curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/default - echo "" - - kill-hello-blue-process: - env: - HTTP_PORT: '8080' - DOMAIN: 'localhost' - PROTOCOL: 'http' - cmds: - - | - curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/blue - echo "" - - kill-hello-green-process: - env: - HTTP_PORT: '8080' - DOMAIN: 'localhost' - PROTOCOL: 'http' - cmds: - - | - curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/green - echo "" - - kill-hello-orange-process: - env: - HTTP_PORT: '8080' - DOMAIN: 'localhost' - PROTOCOL: 'http' - cmds: - - | - curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/orange - echo "" - - stress-average-hello: - env: - DATA: 'Bob Morane' - HTTP_PORT: '8080' - DOMAIN: 'localhost' - PROTOCOL: 'http' - cmds: - - | - hey -n 300 -c 100 -m POST \ - -H "Content-Type: text/plain; charset=utf-8" \ - -d "${DATA}" ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello - - stress-high-hello: - env: - DATA: 'Bob Morane' - HTTP_PORT: '8080' - DOMAIN: 'localhost' - PROTOCOL: 'http' - cmds: - - | - hey -n 10000 -c 6000 -m POST \ - -H "Content-Type: text/plain; charset=utf-8" \ - -d "${DATA}" ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello - + # this curl command does not work processes-list: env: HTTP_PORT: '8080' @@ -462,3 +115,6 @@ tasks: curl -X GET ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/processes + todo: > + - redeploy of index + diff --git a/capsule-http/tests/faas/draft.api.yml b/capsule-http/tests/faas/draft.api.yml new file mode 100644 index 0000000..e04f625 --- /dev/null +++ b/capsule-http/tests/faas/draft.api.yml @@ -0,0 +1,264 @@ + + # ======================================= + # Without capsctl, only the API + # 🚧 WIP + # ======================================= + + launch-hello-functions: + cmds: + - | + FUNCTION_NAME="hello" + FUNCTION_REVISION="default" + WASM_FILE="./functions/hello-default/hello-default.wasm" + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${FUNCTION_REVISION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}"], + "env": [] + } + EOF + - | # 👋 the hello blue function stops after 30 seconds + FUNCTION_NAME="hello" + FUNCTION_REVISION="blue" + WASM_FILE="./functions/hello-blue/hello-blue.wasm" + DURATION=30 + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${FUNCTION_REVISION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}", "-stopAfter=${DURATION}"], + "env": [] + } + EOF + - | + FUNCTION_NAME="hello" + FUNCTION_REVISION="green" + WASM_FILE="./functions/hello-green/hello-green.wasm" + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${FUNCTION_REVISION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}"], + "env": [] + } + EOF + - | + FUNCTION_NAME="hello" + FUNCTION_REVISION="orange" + WASM_FILE="./functions/hello-orange/hello-orange.wasm" + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${FUNCTION_REVISION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}"], + "env": [] + } + EOF + + launch-remote-hello-functions: + env: + GITLAB_WASM_PROJECT_ID: "45020306" + WASM_PACKAGE: "capsule" + cmds: + - | + FUNCTION_NAME="hello" + WASM_VERSION="default" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + WASM_FILE="./tmp/${WASM_MODULE}" + DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${WASM_VERSION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}", "-url=${DOWNLOAD_URL}"], + "env": [] + } + EOF + - | # 👋 the hello blue function stops after 30 seconds + FUNCTION_NAME="hello" + WASM_VERSION="blue" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + WASM_FILE="./tmp/${WASM_MODULE}" + DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + + DURATION=30 + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${WASM_VERSION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}", "-stopAfter=${DURATION}", "-url=${DOWNLOAD_URL}"], + "env": [] + } + EOF + - | + FUNCTION_NAME="hello" + WASM_VERSION="green" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + WASM_FILE="./tmp/${WASM_MODULE}" + DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${WASM_VERSION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}", "-url=${DOWNLOAD_URL}"], + "env": [] + } + EOF + - | + FUNCTION_NAME="hello" + WASM_VERSION="orange" + WASM_MODULE="${FUNCTION_NAME}-${WASM_VERSION}.wasm" + WASM_FILE="./tmp/${WASM_MODULE}" + DOWNLOAD_URL="https://gitlab.com/api/v4/projects/${GITLAB_WASM_PROJECT_ID}/packages/generic/${WASM_PACKAGE}/${WASM_VERSION}/${WASM_MODULE}" + + curl -X POST localhost:8080/functions/start \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d @- << EOF + { + "name":"${FUNCTION_NAME}", + "revision":"${WASM_VERSION}", + "description":"hello function", + "path":"/usr/local/bin/capsule-http", + "args": ["", "-wasm=${WASM_FILE}", "-url=${DOWNLOAD_URL}"], + "env": [] + } + EOF + + + call-hello-functions: + env: + DATA: 'Bob Morane' + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/default \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d "${DATA}" + echo "" + echo "" + - | + curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/blue \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d "${DATA}" + echo "" + echo "" + - | + curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/green \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d "${DATA}" + echo "" + echo "" + - | + curl -X POST ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello/orange \ + -H 'Content-Type: text/plain; charset=utf-8' \ + -d "${DATA}" + echo "" + echo "" + + kill-hello-default-process: + env: + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/default + echo "" + + kill-hello-blue-process: + env: + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/blue + echo "" + + kill-hello-green-process: + env: + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/green + echo "" + + kill-hello-orange-process: + env: + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + curl -X DELETE ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/stop/hello/orange + echo "" + + stress-average-hello: + env: + DATA: 'Bob Morane' + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + hey -n 300 -c 100 -m POST \ + -H "Content-Type: text/plain; charset=utf-8" \ + -d "${DATA}" ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello + + stress-high-hello: + env: + DATA: 'Bob Morane' + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + hey -n 10000 -c 6000 -m POST \ + -H "Content-Type: text/plain; charset=utf-8" \ + -d "${DATA}" ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/hello + + processes-list: + env: + HTTP_PORT: '8080' + DOMAIN: 'localhost' + PROTOCOL: 'http' + cmds: + - | + curl -X GET ${PROTOCOL}://${DOMAIN}:${HTTP_PORT}/functions/processes + + diff --git a/capsule-http/tools/description.txt b/capsule-http/tools/description.txt index 4eb3fc7..1e58c4b 100644 --- a/capsule-http/tools/description.txt +++ b/capsule-http/tools/description.txt @@ -1 +1 @@ -[🌍HTTP🌍] v0.3.9 🥒 [cucumber] \ No newline at end of file +[HTTP] v0.4.0 🌶️ [chili pepper] \ No newline at end of file diff --git a/docs/capsule-http-faas-mode.md b/docs/capsule-http-faas-mode.md index 4a2fd11..110276b 100644 --- a/docs/capsule-http-faas-mode.md +++ b/docs/capsule-http-faas-mode.md @@ -10,7 +10,7 @@ A Capsule HTTP server can start/spawn other Capsule HTTP server processes. ### Install the last version of Capsule HTTP ```bash -VERSION="v0.3.9" OS="linux" ARCH="arm64" +VERSION="v0.4.0" OS="linux" ARCH="arm64" wget -O capsule-http https://github.com/bots-garden/capsule/releases/download/${VERSION}/capsule-http-${VERSION}-${OS}-${ARCH} chmod +x capsule-http sudo cp capsule-http /usr/local/bin/capsule-http @@ -24,7 +24,7 @@ capsule-http --version **CapsCtl** is a CLI to send commands to the Capsule HTTP server when it is unning in **FaaS** mode. ```bash -VERSION="v0.3.9" OS="linux" ARCH="arm64" +VERSION="v0.4.0" OS="linux" ARCH="arm64" wget -O capsctl https://github.com/bots-garden/capsule/releases/download/${VERSION}/capsctl-${VERSION}-${OS}-${ARCH} chmod +x capsctl sudo cp capsctl /usr/local/bin/capsctl @@ -51,7 +51,7 @@ You should get an output like this: ``` 2023/05/29 15:12:18 🚀 faas mode activated! 2023/05/29 15:12:18 📦 wasm module loaded: ./functions/index-page/index-page.wasm -2023/05/29 15:12:18 💊 Capsule [HTTP] v0.3.9 🥒 [cucumber] +2023/05/29 15:12:18 💊 Capsule [HTTP] v0.4.0 🌶️ [chili pepper] http server is listening on: 8080 🌍 ``` diff --git a/docs/capsule-http-flags.md b/docs/capsule-http-flags.md index 4d47ca1..f570696 100644 --- a/docs/capsule-http-flags.md +++ b/docs/capsule-http-flags.md @@ -1,2 +1,3 @@ # 🚩 Capsule HTTP Flags +🚧 This is a work in progress \ No newline at end of file diff --git a/docs/capsule-http-install-pi.md b/docs/capsule-http-install-pi.md index a208c67..76aa702 100644 --- a/docs/capsule-http-install-pi.md +++ b/docs/capsule-http-install-pi.md @@ -9,7 +9,7 @@ ssh k33g@capsulezero.local ## Install Capsule HTTP -VERSION="v0.3.9" OS="linux" ARCH="arm64" +VERSION="v0.3.4" OS="linux" ARCH="arm64" wget -O capsule-http https://github.com/bots-garden/capsule/releases/download/${VERSION}/capsule-http-${VERSION}-${OS}-${ARCH} chmod +x capsule-http ./capsule-http --version @@ -18,7 +18,7 @@ chmod +x capsule-http Or you can copy the appropriate Capsule HTTP binary from your computer to the RPI: ```bash -scp capsule-http-v0.3.9-linux-arm64 k33g@capsulezero.local:./ +scp capsule-http-v0.3.4-linux-arm64 k33g@capsulezero.local:./ ``` ## Start Capsule HTTP FaaS mode diff --git a/docs/capsule-http-ovh-deploy.md b/docs/capsule-http-ovh-deploy.md new file mode 100644 index 0000000..186fbed --- /dev/null +++ b/docs/capsule-http-ovh-deploy.md @@ -0,0 +1,2 @@ +# Deploy Capsule FaaS on OVH Cloud + diff --git a/docs/docker-capsule-http.md b/docs/docker-capsule-http.md index 6b54c06..19c967a 100644 --- a/docs/docker-capsule-http.md +++ b/docs/docker-capsule-http.md @@ -1,8 +1,8 @@ # 🐳 Capsule HTTP Docker image -!!! info "Capsule HTTP Docker images v0.3.9 🥒 [cucumber]" - - `botsgarden/capsule-http-linux-arm64:0.3.9` - - `botsgarden/capsule-http-linux-amd64:0.3.9` +!!! info "Capsule HTTP Docker images v0.4.0 🌶️ [chili pepper]" + - `botsgarden/capsule-http-linux-arm64:0.4.0` + - `botsgarden/capsule-http-linux-amd64:0.4.0` > https://hub.docker.com/repositories/botsgarden @@ -13,7 +13,7 @@ ```bash GOOS="linux" GOARCH="arm64" -IMAGE_TAG="0.3.9" +IMAGE_TAG="0.4.0" IMAGE_NAME="botsgarden/capsule-http-${GOOS}-${GOARCH}" docker run \ @@ -29,7 +29,7 @@ docker run \ Create a new `Dockerfile`: ```dockerfile -FROM botsgarden/capsule-http-linux-arm64:0.3.9 +FROM botsgarden/capsule-http-linux-arm64:0.4.0 COPY hello-world.wasm . EXPOSE 8080 CMD ["/capsule-http", "--wasm=./hello-world.wasm", "--httpPort=8080"] diff --git a/docs/getting-started-cli.md b/docs/getting-started-cli.md index 3be2e3e..b83eb79 100644 --- a/docs/getting-started-cli.md +++ b/docs/getting-started-cli.md @@ -5,7 +5,7 @@ First, download the last version of the Capsule CLI for the appropriate OS & ARCH (and release version): ```bash -VERSION="v0.3.9" OS="linux" ARCH="arm64" +VERSION="v0.4.0" OS="linux" ARCH="arm64" wget -O capsule https://github.com/bots-garden/capsule/releases/download/${VERSION}/capsule-${VERSION}-${OS}-${ARCH} chmod +x capsule ``` diff --git a/docs/getting-started-http-ngrok.md b/docs/getting-started-http-ngrok.md index 1a09655..1ed6b6c 100644 --- a/docs/getting-started-http-ngrok.md +++ b/docs/getting-started-http-ngrok.md @@ -15,7 +15,7 @@ NGROK_AUTHTOKEN="${YOUR_NGROK_AUTHTOKEN}" \ The ouput will be like this: ```bash -2023/05/18 11:25:36 💊 Capsule v0.3.9 🥒 [cucumber] http server is listening on: 6666 🌍 +2023/05/18 11:25:36 💊 Capsule v0.4.0 🌶️ [chili pepper] http server is listening on: 6666 🌍 2023/05/18 11:25:37 👋 Ngrok tunnel created: https://d298-88-173-112-231.ngrok-free.app 2023/05/18 11:25:37 🤚 Ngrok URL: /home/ubuntu/workspaces/capsule/capsule-http/ngrok.url ``` diff --git a/docs/getting-started-http.md b/docs/getting-started-http.md index 70c35c8..aae59e9 100644 --- a/docs/getting-started-http.md +++ b/docs/getting-started-http.md @@ -5,11 +5,43 @@ First, download the last version of the Capsule HTTP server for the appropriate OS & ARCH (and release version): ```bash -VERSION="v0.3.9" OS="linux" ARCH="arm64" +VERSION="v0.4.0" OS="linux" ARCH="arm64" wget -O capsule-http https://github.com/bots-garden/capsule/releases/download/${VERSION}/capsule-http-${VERSION}-${OS}-${ARCH} chmod +x capsule-http ``` +## Write a WASM Capsule module + +```golang +package main + +import ( + "github.com/bots-garden/capsule-module-sdk" +) + +func main() { + + capsule.SetHandleHTTP(func(param capsule.HTTPRequest) (capsule.HTTPResponse, error) { + + response := capsule.HTTPResponse{ + JSONBody: `{"message": "Hello World"}`, + Headers: `{"Content-Type": "application/json; charset=utf-8"}`, + StatusCode: 200, + } + return response, nil + }) +} +``` + +**Build the WASM module**: + +```bash +tinygo build -o hello-world.wasm \ + -scheduler=none \ + --no-debug \ + -target wasi ./main.go +``` + ## Serve a WASM Capsule module To run a WASM Capsule module you need to set 2 flags: @@ -49,6 +81,75 @@ You can remotely download the WASM module with the `--url` flag: > --httpPort=${HTTP_PORT} > ``` +## Monitoring the service + +Capsule HTTP server exposes a REST API (`/metrics` endpoint) that can be used to monitor the service. You have to write the logic to generate the metrics and expose them to Prometheus. + +An HTTP request to the `/metrics` endpoint will trigger the call of the **exposed** `OnMetrics` function of the WASM module. You need to implement the `OnMetrics` function in your WASM module: + +```golang +//export OnMetrics +func OnMetrics() uint64 { + + // Generate OpenText Prometheus metric + counterMetrics := []string{ + "# HELP call counter", + "# TYPE call_counter counter", + "call_counter " + strconv.Itoa(counter)} + + response := capsule.HTTPResponse{ + TextBody: strings.Join(counterMetrics, "\n"), + Headers: `{"Content-Type": "text/plain; charset=utf-8"}`, + StatusCode: 200, + } + return capsule.Success([]byte(capsule.StringifyHTTPResponse(response))) + +} +``` +> - Don't forget to expose the function: `//export OnMetrics` +> - You can find a complete sample here: [hello-world sample](https://github.com/bots-garden/capsule/blob/main/capsule-http/functions/hello-world/main.go) + +## Health Check + +Capsule HTTP server exposes a REST API (`/health` endpoint) that can be used to teturn a health status. You have to write the logic to generate the status. + +An HTTP request to the `/health` endpoint will trigger the call of the **exposed** `OnHealthCheck` function of the WASM module. You need to implement the `OnHealthCheck` function in your WASM module: + +```golang +//export OnHealthCheck +func OnHealthCheck() uint64 { + + response := capsule.HTTPResponse{ + JSONBody: `{"message": "OK"}`, + Headers: `{"Content-Type": "application/json; charset=utf-8"}`, + StatusCode: 200, + } + + return capsule.Success([]byte(capsule.StringifyHTTPResponse(response))) +} +``` +> - Don't forget to expose the function: `//export OnHealthCheck` +> - You can find a complete sample here: [hello-world sample](https://github.com/bots-garden/capsule/blob/main/capsule-http/functions/hello-world/main.go) + +## `OnStart` and `OnStop` functions + +You can add a `OnStart` and `OnStop` function to the WASM module. These functions will be called when the service starts and stops. + +```golang +//export OnStart +func OnStart() { + capsule.Print("🚗 OnStart") +} + +//export OnStop +func OnStop() { + capsule.Print("🚙 OnStop") +} +``` +> - Don't forget to expose the functions +> - You can find a complete sample here: [hello-world sample](https://github.com/bots-garden/capsule/blob/main/capsule-http/functions/hello-world/main.go) + + ## Develop a WASM Capsule module Have a look to these samples: diff --git a/docs/index.md b/docs/index.md index a853e8f..f1876f0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,7 @@ # Capsule Project: the nano wasm runners !!! info "What's new?" + - `v0.4.0 🌶️ [chili pepper]`: update of [HDK 0.0.4 then 0.0.5](https://github.com/bots-garden/capsule-host-sdk/releases/tag/v0.0.5), (🎉 performances: more than x 2 🚀). **capsule-http**: add of 2 endpoints (`/metrics`and `/health`) triggering the `OnMetrics` and `OnHealthCheck` functions of the WASM module. - `v0.3.9 🥒 [cucumber]`: update of [HDK 0.0.3](https://github.com/bots-garden/capsule-host-sdk) with [Wazero 1.2.0](https://github.com/tetratelabs/wazero/releases/tag/v1.2.0) and [MDK 0.0.3](https://github.com/bots-garden/capsule-module-sdk) (encoding of the HTML string into JSON string, then it's easier to serve HTML) - `v0.3.8 🥬 [leafy greens]`: 🐛 fixes of the **FaaS** mode - `v0.3.7 🥦 [broccoli]`: 🚀 **FaaS** mode (documentation in progress) + **NGrok** integration @@ -64,7 +65,6 @@ func Handle(params []byte) ([]byte, error) { return []byte("👋 Hello " + string(params)), nil } - ``` ### WASM Module for the Capsule HTTP server diff --git a/mkdocs.yml b/mkdocs.yml index 077bd9d..35c0e29 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,6 +24,7 @@ nav: - 🥘 Recipes: - Serve HTML: capsule-http-serve-html.md - Install Capsule on a Pi: capsule-http-install-pi.md + - Capsule FaaS on OVH-Cloud: capsule-http-ovh-deploy.md - 🏭 Capsule HTTP Enterprise: capsule-http-enterprise.md theme: diff --git a/release/README.md b/release/README.md index 4c80425..37d7c5a 100644 --- a/release/README.md +++ b/release/README.md @@ -6,6 +6,7 @@ 👋 **be on the main branch** +Last release: `v0.4.0 🌶️ [chili pepper]` Last release: `v0.3.9 🥒 [cucumber]` Last release: `v0.3.8 🥬 [leafy greens]` Last release: `v0.3.7 🥦 [broccoli]` @@ -17,7 +18,7 @@ Check every documents: ### Update version number in Go source -- `capsule-http/description.txt` +- `capsule-http/tools/description.txt` - `capsule-cli/description.txt` - `capsctl/description.txt`