Skip to content

Commit 964aa3e

Browse files
committed
🌺 gardening modules samples
1 parent 9a0b98b commit 964aa3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+81
-332
lines changed

capsule-launcher/about.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
----------------------
22
Capsule project 💊
3-
v0.0.0
43
By @k33g
54
----------------------

wasm_modules/capsule-files/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
capsule

wasm_modules/capsule-files/build.sh

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/bin/bash
2-
#tinygo build -o hello.wasm -scheduler=none --no-debug -target wasi ./hello.go
32
tinygo build -o hello.wasm -scheduler=none -target wasi ./hello.go
43

5-
#tinygo build -o hello.wasm -target wasi ./hello.go
6-
74
ls -lh *.wasm

wasm_modules/capsule-files/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module github.com/bots-garden/capsule/wasm_modules/capsule-files
22

33
go 1.18
44

5-
require github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730132531-d288ee6b97a4
5+
require github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815080256-b30492298265
66

7-
require github.com/bots-garden/capsule/capsulelauncher v0.0.0-20220730130303-2f1fc7ff9b42 // indirect
7+
require github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3 // indirect

wasm_modules/capsule-files/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github.com/bots-garden/capsule/capsulelauncher v0.0.0-20220730130303-2f1fc7ff9b42 h1:kKuAszSBijZengtPIVapkk049SXE5wzklcP64v42zHw=
2-
github.com/bots-garden/capsule/capsulelauncher v0.0.0-20220730130303-2f1fc7ff9b42/go.mod h1:At1Ce+IGheweU8baD/ZvD0DS64O7fpNZzrXFuQjDO8I=
3-
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730132531-d288ee6b97a4 h1:px42oVTpc/FntKs4fCcbfzLk7z6PorlUTlxRivd/Tvo=
4-
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730132531-d288ee6b97a4/go.mod h1:CFuO1UNMvehwFZImG7hyN8rEpX+rE8fSazyvUNaueEQ=
1+
github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3 h1:jd6GhVtU6hJh2YhTOal46CxbSfGALQOw+QdwC4N/7eg=
2+
github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3/go.mod h1:PBhXY24j6vjuYghjEt+9mXzDb2ZwD9m9PAh9e6FTXck=
3+
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815080256-b30492298265 h1:dwYIdkYYkkxDubatShvKT+nGNKHEtIzTx2dhuuGY8jQ=
4+
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815080256-b30492298265/go.mod h1:tu9DYBPXGSfiDaCN1opAFZZ3FFt3TVFH5jkYnPypY64=

wasm_modules/capsule-files/refresh_package.sh

-12
This file was deleted.

wasm_modules/capsule-files/run-cli-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
cd ../../capsulelauncher
2+
cd ../../capsule-launcher
33

44
export MESSAGE="💊 Capsule Rocks 🚀"
55
go run main.go \

wasm_modules/capsule-files/run.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
export MESSAGE="💊 Capsule Rocks 🚀"
3+
./capsule \
4+
-wasm=./hello.wasm \
5+
-mode=cli \
6+
"👋 hello world 🌍🎃" 1234 "Bob Morane"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
capsule

wasm_modules/capsule-hello-get/README.md

+12-18
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
This wasm module is used by the `http` mode
44

5-
## Load (and run) the wasm file module from a local path
5+
## Build the wasm module
66

77
```bash
8-
cd ../../capsulelauncher
8+
tinygo build -o hello.wasm -scheduler=none -target wasi ./hello.go
9+
```
10+
11+
## Load (and run) the wasm file module from a local path
912

10-
export MESSAGE="💊 Capsule Rocks 🚀"
11-
go run main.go \
12-
-wasm=../wasm_modules/capsule-hello/hello.wasm \
13+
```bash
14+
./capsule \
15+
-wasm=./hello.wasm \
1316
-mode=http \
1417
-httpPort=7070
1518
```
1619

1720
Then call the wasm function:
1821
```bash
19-
curl -v -X POST \
20-
http://localhost:7070 \
21-
-H 'content-type: application/json; charset=utf-8' \
22-
-d '{"message": "Golang 💚 wasm", "author": "Philippe"}'
22+
curl -v http://localhost:7070
2323
```
2424

25-
## Load (and run) the wasm file module from an URL
25+
## Load (and run) the wasm file module from a URL
2626

2727
First serve the wasm file:
2828
```bash
@@ -31,10 +31,7 @@ python3 -m http.server 8080
3131

3232
Then load and serve the module: *(the `wasm` file is the output of the download file)*
3333
```bash
34-
cd ../../capsulelauncher
35-
36-
export MESSAGE="💊 Capsule Rocks 🚀"
37-
go run main.go \
34+
./capsule \
3835
-wasm=./tmp/hello.wasm \
3936
-url="http://localhost:8080/hello.wasm" \
4037
-mode=http \
@@ -43,8 +40,5 @@ go run main.go \
4340

4441
Then call the wasm function:
4542
```bash
46-
curl -v -X POST \
47-
http://localhost:7070 \
48-
-H 'content-type: application/json; charset=utf-8' \
49-
-d '{"message": "Golang 💚 wasm", "author": "Philippe"}'
43+
curl -v http://localhost:7070
5044
```
-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/bin/bash
2-
#tinygo build -o hello.wasm -scheduler=none --no-debug -target wasi ./hello.go
32
tinygo build -o hello.wasm -scheduler=none -target wasi ./hello.go
43

5-
#tinygo build -o hello.wasm -target wasi ./hello.go
6-
74
ls -lh *.wasm

wasm_modules/capsule-hello-get/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module github.com/bots-garden/capsule/wasm_modules/capsule-hello-get
22

33
go 1.18
44

5-
require github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730154229-17372954e5a4
5+
require github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815080256-b30492298265
66

7-
require github.com/bots-garden/capsule/capsulelauncher v0.0.0-20220730135606-1eede3f3645a // indirect
7+
require github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3 // indirect

wasm_modules/capsule-hello-get/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github.com/bots-garden/capsule/capsulelauncher v0.0.0-20220730135606-1eede3f3645a h1:MbKeIW07LpiEh+Zp6RiiKynwan6CGip5+XbE4xHQfcw=
2-
github.com/bots-garden/capsule/capsulelauncher v0.0.0-20220730135606-1eede3f3645a/go.mod h1:At1Ce+IGheweU8baD/ZvD0DS64O7fpNZzrXFuQjDO8I=
3-
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730154229-17372954e5a4 h1:xhT0AWINVJqM7wjnD6rqDC1HlSb/3u2aNSakKVo5VHg=
4-
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730154229-17372954e5a4/go.mod h1:q4AQUEwpNcNmkaPQxMac5UF9BfpxGJ3jUiXx+aiD3No=
1+
github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3 h1:jd6GhVtU6hJh2YhTOal46CxbSfGALQOw+QdwC4N/7eg=
2+
github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3/go.mod h1:PBhXY24j6vjuYghjEt+9mXzDb2ZwD9m9PAh9e6FTXck=
3+
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815080256-b30492298265 h1:dwYIdkYYkkxDubatShvKT+nGNKHEtIzTx2dhuuGY8jQ=
4+
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815080256-b30492298265/go.mod h1:tu9DYBPXGSfiDaCN1opAFZZ3FFt3TVFH5jkYnPypY64=

wasm_modules/capsule-hello-get/load-http-test.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/bash
22

33
# before serve the wasm file: python3 -m http.server 8080
4-
cd ../../capsulelauncher
4+
cd ../../capsule-launcher
55

6-
export MESSAGE="💊 Capsule Rocks 🚀"
76
go run main.go \
87
-wasm=./tmp/hello.wasm \
98
-url="http://localhost:8080/hello.wasm" \

wasm_modules/capsule-hello-get/refresh_package.sh

-13
This file was deleted.

wasm_modules/capsule-hello-get/run-http-test.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
2-
cd ../../capsulelauncher
2+
cd ../../capsule-launcher
33

4-
export MESSAGE="💊 Capsule Rocks 🚀"
54
go run main.go \
65
-wasm=../wasm_modules/capsule-hello-get/hello.wasm \
76
-mode=http \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
capsule

wasm_modules/capsule-hello-post/README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
This wasm module is used by the `http` mode
44

5-
## Load (and run) the wasm file module from a local path
5+
## Build the wasm module
66

77
```bash
8-
cd ../../capsulelauncher
8+
tinygo build -o hello.wasm -scheduler=none -target wasi ./hello.go
9+
```
10+
11+
## Load (and run) the wasm file module from a local path
912

13+
```bash
1014
export MESSAGE="💊 Capsule Rocks 🚀"
11-
go run main.go \
12-
-wasm=../wasm_modules/capsule-hello/hello.wasm \
15+
./capsule \
16+
-wasm=./hello.wasm \
1317
-mode=http \
1418
-httpPort=7070
1519
```
@@ -31,10 +35,8 @@ python3 -m http.server 8080
3135

3236
Then load and serve the module: *(the `wasm` file is the output of the download file)*
3337
```bash
34-
cd ../../capsulelauncher
35-
3638
export MESSAGE="💊 Capsule Rocks 🚀"
37-
go run main.go \
39+
./capsule \
3840
-wasm=./tmp/hello.wasm \
3941
-url="http://localhost:8080/hello.wasm" \
4042
-mode=http \
-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/bin/bash
2-
#tinygo build -o hello.wasm -scheduler=none --no-debug -target wasi ./hello.go
32
tinygo build -o hello.wasm -scheduler=none -target wasi ./hello.go
43

5-
#tinygo build -o hello.wasm -target wasi ./hello.go
6-
74
ls -lh *.wasm

wasm_modules/capsule-hello-post/go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ module github.com/bots-garden/capsule/wasm_modules/capsule-hello-post
33
go 1.18
44

55
require (
6-
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730130303-2f1fc7ff9b42
7-
github.com/tidwall/gjson v1.14.1
8-
github.com/tidwall/sjson v1.2.4
6+
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815084835-9a0b98b22e4a
7+
github.com/tidwall/gjson v1.14.2
8+
github.com/tidwall/sjson v1.2.5
99
)
1010

1111
require (
12-
github.com/google/uuid v1.3.0 // indirect
12+
github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3 // indirect
1313
github.com/tidwall/match v1.1.1 // indirect
1414
github.com/tidwall/pretty v1.2.0 // indirect
1515
)
+8-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730130303-2f1fc7ff9b42 h1:riAchPaItxFGUp9v1b35fT3Uvgm9DhiH2p51mn3Is0o=
2-
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220730130303-2f1fc7ff9b42/go.mod h1:Jfr80DRo5cX0VRebVcS9R802zH/uKcljiE6uC2iNUyo=
3-
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
4-
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5-
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
6-
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
7-
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
1+
github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3 h1:jd6GhVtU6hJh2YhTOal46CxbSfGALQOw+QdwC4N/7eg=
2+
github.com/bots-garden/capsule v0.0.0-20220815052111-84fb610d29f3/go.mod h1:PBhXY24j6vjuYghjEt+9mXzDb2ZwD9m9PAh9e6FTXck=
3+
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815084835-9a0b98b22e4a h1:eGcBQabgdwqG7oVjGJyqYYzJ7yf3eyRHniJROsBplQ0=
4+
github.com/bots-garden/capsule/capsulemodule v0.0.0-20220815084835-9a0b98b22e4a/go.mod h1:tu9DYBPXGSfiDaCN1opAFZZ3FFt3TVFH5jkYnPypY64=
5+
github.com/tidwall/gjson v1.14.2 h1:6BBkirS0rAHjumnjHF6qgy5d2YAJ1TLIaFE2lzfOLqo=
6+
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
87
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
98
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
109
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
1110
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
12-
github.com/tidwall/sjson v1.2.4 h1:cuiLzLnaMeBhRmEv00Lpk3tkYrcxpmbU81tAY4Dw0tc=
13-
github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM=
11+
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
12+
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=

wasm_modules/capsule-hello-post/http-next.txt

-46
This file was deleted.

wasm_modules/capsule-hello-post/http.txt

-46
This file was deleted.

wasm_modules/capsule-hello-post/load-http-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# before serve the wasm file: python3 -m http.server 8080
4-
cd ../../capsulelauncher
4+
cd ../../capsule-launcher
55

66
export MESSAGE="💊 Capsule Rocks 🚀"
77
go run main.go \

0 commit comments

Comments
 (0)