Skip to content

Commit b62d43f

Browse files
committed
update componentize-go and make use of new features
Per bytecodealliance/componentize-go#35, Spin applications can now refer to WIT files by way of the `github.com/spinframework/spin-go-sdk/v3` source package; no need for the application to supply them itself. That PR also allows us to pass multiple `--world` flags to `componentize-go`, allowing us to target e.g. the `fermyon:spin/redis-trigger` _and_ `spin:up/platform` worlds at the same time (which is what Spin actually implements for Redis triggers). Signed-off-by: Joel Dice <joel.dice@akamai.com>
1 parent 076eeda commit b62d43f

84 files changed

Lines changed: 140 additions & 143 deletions

File tree

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
uses: dtolnay/rust-toolchain@stable
2323

2424
- name: Install componentize-go
25-
# TODO: Switch to pre-built release once new one is available (i.e. post-v0.2.0):
26-
run: cargo install --locked --git https://github.com/bytecodealliance/componentize-go --rev 94413331
25+
# TODO: Switch to an upstream (pre-built) release once new one is available and includes https://github.com/bytecodealliance/componentize-go/pull/35
26+
run: cargo install --locked --git https://github.com/dicej/componentize-go --rev aa2645d2
2727

2828
- name: Install Spin
2929
uses: fermyon/actions/spin/setup@v1

Makefile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ regenerate-bindings:
1313
-maxdepth 1 \
1414
-type d \
1515
! -name 'db' \
16-
! -name 'export_wasi_http_0_2_0_incoming_handler' \
17-
-exec rm -rf {} +
18-
componentize-go -w http-trigger -d ./wit bindings --format -o internal --pkg-name github.com/spinframework/spin-go-sdk/v3/internal
19-
find $$(pwd)/inbound_redis/internal/ \
20-
-mindepth 1 \
21-
-maxdepth 1 \
22-
-type d \
2316
! -name 'export_fermyon_spin_inbound_redis' \
17+
! -name 'export_wasi_http_0_2_0_incoming_handler' \
2418
-exec rm -rf {} +
25-
componentize-go -w fermyon:spin/redis-trigger -d ./wit bindings --format -o inbound_redis/internal --pkg-name github.com/spinframework/spin-go-sdk/v3/inbound_redis/internal
19+
componentize-go -w http-trigger -w fermyon:spin/redis-trigger -d ./wit bindings --format -o internal --pkg-name github.com/spinframework/spin-go-sdk/v3/internal

examples/http-outbound/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Building this as a WebAssembly module can be done using `spin build`:
1010

1111
```shell
1212
$ spin build
13-
Building component http-to-same-app with `componentize-go --world http-trigger --wit-path ../../../wit build`
13+
Building component http-to-same-app with `componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build`
1414
Working directory: "./http-to-same-app"
15-
Building component hello with `componentize-go --world http-trigger --wit-path ../../../wit build`
15+
Building component hello with `componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build`
1616
Working directory: "./hello"
1717
Finished building all Spin components
1818
```

examples/http-outbound/spin.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ allowed_outbound_hosts = [
2222
]
2323
[component.hello.build]
2424
workdir = "hello"
25-
command = "componentize-go --world http-trigger --wit-path ../../../wit build"
25+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"
2626

2727
[component.http-to-same-app]
2828
source = "http-to-same-app/main.wasm"
2929
# Use self to make outbound requests to components in the same Spin application.
3030
allowed_outbound_hosts = ["http://self"]
3131
[component.http-to-same-app.build]
3232
workdir = "http-to-same-app"
33-
command = "componentize-go --world http-trigger --wit-path ../../../wit build"
33+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"
3434

examples/http-router/spin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ component = "hello"
1313
[component.hello]
1414
source = "main.wasm"
1515
[component.hello.build]
16-
command = "componentize-go --world http-trigger --wit-path ../../wit build"
16+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"

examples/http/spin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ component = "hello"
1313
[component.hello]
1414
source = "main.wasm"
1515
[component.hello.build]
16-
command = "componentize-go --world http-trigger --wit-path ../../wit build"
16+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"

examples/key-value/spin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ component = "hello"
1414
source = "main.wasm"
1515
key_value_stores = ["default"]
1616
[component.hello.build]
17-
command = "componentize-go --world http-trigger --wit-path ../../wit build"
17+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"

examples/llm/spin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ source = "main.wasm"
1515
allowed_outbound_hosts = []
1616
ai_models = ["llama2-chat", "all-minilm-l6-v2"]
1717
[component.llm.build]
18-
command = "componentize-go --world http-trigger --wit-path ../../wit build"
18+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"
1919
watch = ["**/*.go", "go.mod"]

examples/mqtt-outbound/spin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ source = "main.wasm"
1616
environment = { MQTT_ADDRESS = "mqtt://127.0.0.1:1883?client_id=client001", MQTT_USERNAME = "user", MQTT_PASSWORD = "password", MQTT_KEEP_ALIVE_INTERVAL = "30", MQTT_TOPIC = "telemetry" }
1717
allowed_outbound_hosts = ["mqtt://127.0.0.1:1883"]
1818
[component.mqtt-outbound.build]
19-
command = "componentize-go --world http-trigger --wit-path ../../wit build"
19+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"
2020
watch = ["**/*.go", "go.mod"]

examples/mysql-outbound/spin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ environment = { DB_URL = "mysql://spin:spin@127.0.0.1/spin_data" }
1515
source = "main.wasm"
1616
allowed_outbound_hosts = ["mysql://127.0.0.1"]
1717
[component.mysql.build]
18-
command = "componentize-go --world http-trigger --wit-path ../../wit build"
18+
command = "componentize-go --world http-trigger --wit-module github.com/spinframework/spin-go-sdk/v3 build"
1919
watch = ["**/*.go", "go.mod"]

0 commit comments

Comments
 (0)