update dependencies

This commit is contained in:
Lorenzo Venerandi 2024-12-14 01:26:30 +01:00
parent cb51ae31e7
commit 9a788f9858
13 changed files with 330 additions and 510 deletions

6
.gitignore vendored
View File

@ -1,4 +1,4 @@
gen/* gen/*
build/* build/*
creds.json creds.json

View File

@ -1,43 +1,43 @@
# HTTP Hello World # HTTP Hello World
This is a simple TinyGo Wasm example that responds with a "Hello World" message for each request. This is a simple TinyGo Wasm example that responds with a "Hello World" message for each request.
## Prerequisites ## Prerequisites
- `go` 1.23 - `go` 1.23
- `tinygo` 0.33 - `tinygo` 0.33
- [`wash`](https://wasmcloud.com/docs/installation) 0.35.0 - [`wash`](https://wasmcloud.com/docs/installation) 0.35.0
- `wasmtime` 25.0.0 (if running with wasmtime) - `wasmtime` 25.0.0 (if running with wasmtime)
## Building ## Building
```bash ```bash
wash build wash build
``` ```
## Push OCI Artifact to Gitea ## Push OCI Artifact to Gitea
```bash ```bash
wash push gitea.rebus.ninja/lore/go-nats-client:1.x.x build/go_nats_client_s.wasm wash push gitea.rebus.ninja/lore/go-nats-client:1.x.x build/go_nats_client_s.wasm
``` ```
## Running with wasmtime ## Running with wasmtime
You must have wasmtime 25.0.0 for this to work. Make sure to follow the build step above first. You must have wasmtime 25.0.0 for this to work. Make sure to follow the build step above first.
```bash ```bash
wasmtime serve -Scommon ./build/http_hello_world_s.wasm wasmtime serve -Scommon ./build/http_hello_world_s.wasm
``` ```
## Running with wasmCloud ## Running with wasmCloud
Make sure to follow the build steps above, and replace the file path in [the wadm manifest](./wadm.yaml) with the absolute path to your local built component. Make sure to follow the build steps above, and replace the file path in [the wadm manifest](./wadm.yaml) with the absolute path to your local built component.
```shell ```shell
wash up -d wash up -d
wash app deploy ./wadm.yaml wash app deploy ./wadm.yaml
curl http://localhost:8000 curl http://localhost:8000
``` ```
## Adding Capabilities ## Adding Capabilities
To learn how to extend this example with additional capabilities, see the [Adding Capabilities](https://wasmcloud.com/docs/tour/adding-capabilities?lang=tinygo) section of the wasmCloud documentation. To learn how to extend this example with additional capabilities, see the [Adding Capabilities](https://wasmcloud.com/docs/tour/adding-capabilities?lang=tinygo) section of the wasmCloud documentation.

View File

@ -1,171 +0,0 @@
//go:build !wasm && !wasi && !wasip1 && !wasip2 && !wasm_unknown && !tinygo.wasm
// Code generated by wadge-bindgen-go DO NOT EDIT
package main
import (
gitea_rebus_ninja__lore__go___nats___client__gen__wasi__config__runtime "gitea.rebus.ninja/lore/go-nats-client/gen/wasi/config/runtime"
gitea_rebus_ninja__lore__go___nats___client__gen__wasmcloud__messaging__consumer "gitea.rebus.ninja/lore/go-nats-client/gen/wasmcloud/messaging/consumer"
gitea_rebus_ninja__lore__go___nats___client__gen__wasmcloud__messaging__types "gitea.rebus.ninja/lore/go-nats-client/gen/wasmcloud/messaging/types"
github_com__bytecodealliance__wasm___tools___go__cm "github.com/bytecodealliance/wasm-tools-go/cm"
wadge "go.wasmcloud.dev/wadge"
"runtime"
"unsafe"
)
const _ string = runtime.Compiler
var _ unsafe.Pointer
//go:linkname wasmimport_Get gitea.rebus.ninja/lore/go-nats-client/gen/wasi/config/runtime.wasmimport_Get
func wasmimport_Get(key0 *uint8, key1 uint32, result *github_com__bytecodealliance__wasm___tools___go__cm.Result[gitea_rebus_ninja__lore__go___nats___client__gen__wasi__config__runtime.OptionStringShape, github_com__bytecodealliance__wasm___tools___go__cm.Option[string], gitea_rebus_ninja__lore__go___nats___client__gen__wasi__config__runtime.ConfigError]) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasi:config/runtime@0.2.0-draft", "get", func() unsafe.Pointer {
ptr := unsafe.Pointer(key0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&key1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(result)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}
//go:linkname wasmimport_GetAll gitea.rebus.ninja/lore/go-nats-client/gen/wasi/config/runtime.wasmimport_GetAll
func wasmimport_GetAll(result *github_com__bytecodealliance__wasm___tools___go__cm.Result[gitea_rebus_ninja__lore__go___nats___client__gen__wasi__config__runtime.ConfigErrorShape, github_com__bytecodealliance__wasm___tools___go__cm.List[[2]string], gitea_rebus_ninja__lore__go___nats___client__gen__wasi__config__runtime.ConfigError]) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasi:config/runtime@0.2.0-draft", "get-all", func() unsafe.Pointer {
ptr := unsafe.Pointer(result)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}
//go:linkname wasmimport_Log gitea.rebus.ninja/lore/go-nats-client/gen/wasi/logging/logging.wasmimport_Log
func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasi:logging/logging@0.1.0-draft", "log", func() unsafe.Pointer {
ptr := unsafe.Pointer(&level0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(context0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&context1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(message0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&message1)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}
//go:linkname wasmimport_Publish gitea.rebus.ninja/lore/go-nats-client/gen/wasmcloud/messaging/consumer.wasmimport_Publish
func wasmimport_Publish(msg0 *uint8, msg1 uint32, msg2 *uint8, msg3 uint32, msg4 uint32, msg5 *uint8, msg6 uint32, result *github_com__bytecodealliance__wasm___tools___go__cm.Result[string, struct{}, string]) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasmcloud:messaging/consumer@0.2.0", "publish", func() unsafe.Pointer {
ptr := unsafe.Pointer(msg0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(msg2)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg3)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg4)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(msg5)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg6)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(result)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}
//go:linkname wasmimport_Request gitea.rebus.ninja/lore/go-nats-client/gen/wasmcloud/messaging/consumer.wasmimport_Request
func wasmimport_Request(subject0 *uint8, subject1 uint32, body0 *uint8, body1 uint32, timeoutMs0 uint32, result *github_com__bytecodealliance__wasm___tools___go__cm.Result[gitea_rebus_ninja__lore__go___nats___client__gen__wasmcloud__messaging__consumer.BrokerMessageShape, gitea_rebus_ninja__lore__go___nats___client__gen__wasmcloud__messaging__types.BrokerMessage, string]) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasmcloud:messaging/consumer@0.2.0", "request", func() unsafe.Pointer {
ptr := unsafe.Pointer(subject0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&subject1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(body0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&body1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&timeoutMs0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(result)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}

50
go.mod
View File

@ -1,25 +1,25 @@
module gitea.rebus.ninja/lore/go-nats-client module gitea.rebus.ninja/lore/go-nats-client
go 1.23.0 go 1.23.0
require ( require (
github.com/bytecodealliance/wasm-tools-go v0.3.2 github.com/bytecodealliance/wasm-tools-go v0.3.2
go.wasmcloud.dev/component v0.0.5 go.wasmcloud.dev/component v0.0.5
go.wasmcloud.dev/wadge v0.7.0 go.wasmcloud.dev/wadge v0.7.0
) )
require ( require (
github.com/coreos/go-semver v0.3.1 // indirect github.com/coreos/go-semver v0.3.1 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/compress v1.17.11 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/regclient/regclient v0.8.0 // indirect github.com/regclient/regclient v0.8.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect github.com/sirupsen/logrus v1.9.3 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect github.com/ulikunitz/xz v0.5.12 // indirect
github.com/urfave/cli/v3 v3.0.0-beta1 // indirect github.com/urfave/cli/v3 v3.0.0-beta1 // indirect
go.bytecodealliance.org v0.4.1 // indirect go.bytecodealliance.org v0.4.1 // indirect
golang.org/x/mod v0.22.0 // indirect golang.org/x/mod v0.22.0 // indirect
golang.org/x/sync v0.10.0 // indirect golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect golang.org/x/sys v0.28.0 // indirect
golang.org/x/tools v0.28.0 // indirect golang.org/x/tools v0.28.0 // indirect
) )

104
go.sum
View File

@ -1,52 +1,52 @@
github.com/bytecodealliance/wasm-tools-go v0.3.2 h1:LKni9PS8yCG5/A79L8tcTKthgf7WN5RZD83W1m6wEE0= github.com/bytecodealliance/wasm-tools-go v0.3.2 h1:LKni9PS8yCG5/A79L8tcTKthgf7WN5RZD83W1m6wEE0=
github.com/bytecodealliance/wasm-tools-go v0.3.2/go.mod h1:fdysX1+SiPxcIhdpg8TLhoxz23k28/5cQ0/L9J4mgig= github.com/bytecodealliance/wasm-tools-go v0.3.2/go.mod h1:fdysX1+SiPxcIhdpg8TLhoxz23k28/5cQ0/L9J4mgig=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4=
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/olareg/olareg v0.1.1 h1:Ui7q93zjcoF+U9U71sgqgZWByDoZOpqHitUXEu2xV+g= github.com/olareg/olareg v0.1.1 h1:Ui7q93zjcoF+U9U71sgqgZWByDoZOpqHitUXEu2xV+g=
github.com/olareg/olareg v0.1.1/go.mod h1:w8NP4SWrHHtxsFaUiv1lnCnYPm4sN1seCd2h7FK/dc0= github.com/olareg/olareg v0.1.1/go.mod h1:w8NP4SWrHHtxsFaUiv1lnCnYPm4sN1seCd2h7FK/dc0=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/regclient/regclient v0.8.0 h1:xNAMDlADcyMvFAlGXoqDOxlSUBG4mqWBFgjQqVTP8Og= github.com/regclient/regclient v0.8.0 h1:xNAMDlADcyMvFAlGXoqDOxlSUBG4mqWBFgjQqVTP8Og=
github.com/regclient/regclient v0.8.0/go.mod h1:h9+Y6dBvqBkdlrj6EIhbTOv0xUuIFl7CdI1bZvEB42g= github.com/regclient/regclient v0.8.0/go.mod h1:h9+Y6dBvqBkdlrj6EIhbTOv0xUuIFl7CdI1bZvEB42g=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli/v3 v3.0.0-beta1 h1:6DTaaUarcM0wX7qj5Hcvs+5Dm3dyUTBbEwIWAjcw9Zg= github.com/urfave/cli/v3 v3.0.0-beta1 h1:6DTaaUarcM0wX7qj5Hcvs+5Dm3dyUTBbEwIWAjcw9Zg=
github.com/urfave/cli/v3 v3.0.0-beta1/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y= github.com/urfave/cli/v3 v3.0.0-beta1/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y=
go.bytecodealliance.org v0.4.1 h1:Y3Nnz+C061i9Hw4qQlSkZTg3IBTsTLC92+sdh4xCADQ= go.bytecodealliance.org v0.4.1 h1:Y3Nnz+C061i9Hw4qQlSkZTg3IBTsTLC92+sdh4xCADQ=
go.bytecodealliance.org v0.4.1/go.mod h1:jxAxqtTxs+6Q2q6bQnWa/lF+Q+2/LkdbqIgNJYxEmFA= go.bytecodealliance.org v0.4.1/go.mod h1:jxAxqtTxs+6Q2q6bQnWa/lF+Q+2/LkdbqIgNJYxEmFA=
go.wasmcloud.dev/component v0.0.5 h1:z9+fq1CJKm/yom33ctd5wfo8TVunm5IaI7EJdY2i9hk= go.wasmcloud.dev/component v0.0.5 h1:z9+fq1CJKm/yom33ctd5wfo8TVunm5IaI7EJdY2i9hk=
go.wasmcloud.dev/component v0.0.5/go.mod h1:PvVHQ7Xp8D9kZnVB3fm8lqWAcC6Yxd7CI/snXZUAG8E= go.wasmcloud.dev/component v0.0.5/go.mod h1:PvVHQ7Xp8D9kZnVB3fm8lqWAcC6Yxd7CI/snXZUAG8E=
go.wasmcloud.dev/wadge v0.7.0 h1:eUt0jODh6xQ5HEof1PFSgDp+evrNs+lD1LYCYeRR2Cg= go.wasmcloud.dev/wadge v0.7.0 h1:eUt0jODh6xQ5HEof1PFSgDp+evrNs+lD1LYCYeRR2Cg=
go.wasmcloud.dev/wadge v0.7.0/go.mod h1:SMnPSWZFTkXyUX0GJ11mcdc7ZoMITtbAlPLlpvGJd4M= go.wasmcloud.dev/wadge v0.7.0/go.mod h1:SMnPSWZFTkXyUX0GJ11mcdc7ZoMITtbAlPLlpvGJd4M=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -1,66 +1,66 @@
apiVersion: core.oam.dev/v1beta1 apiVersion: core.oam.dev/v1beta1
kind: Application kind: Application
metadata: metadata:
name: tinygo-hello-world name: tinygo-hello-world
annotations: annotations:
description: 'HTTP hello world demo in Golang (TinyGo), using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)' description: 'HTTP hello world demo in Golang (TinyGo), using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)'
wasmcloud.dev/authors: wasmCloud team wasmcloud.dev/authors: wasmCloud team
wasmcloud.dev/source-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/golang/components/http-hello-world/wadm.yaml wasmcloud.dev/source-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/golang/components/http-hello-world/wadm.yaml
wasmcloud.dev/readme-md-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/golang/components/http-hello-world/README.md wasmcloud.dev/readme-md-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/golang/components/http-hello-world/README.md
wasmcloud.dev/homepage: https://github.com/wasmCloud/wasmCloud/tree/main/examples/golang/components/http-hello-world wasmcloud.dev/homepage: https://github.com/wasmCloud/wasmCloud/tree/main/examples/golang/components/http-hello-world
wasmcloud.dev/categories: | wasmcloud.dev/categories: |
http,outgoing-http,http-server,tinygo,golang,example http,outgoing-http,http-server,tinygo,golang,example
spec: spec:
components: components:
- name: echo - name: echo
type: component type: component
properties: properties:
# To use the locally compiled code in this folder, use the line below instead after running `wash build`: # To use the locally compiled code in this folder, use the line below instead after running `wash build`:
image: file://./build/go_nats_client_s.wasm image: file://./build/go_nats_client_s.wasm
# image: gitea.rebus.ninja/lore/go-nats-client:1.0.1 # image: gitea.rebus.ninja/lore/go-nats-client:1.0.1
id: echo id: echo
traits: traits:
# Govern the spread/scheduling of the component # Govern the spread/scheduling of the component
- type: spreadscaler - type: spreadscaler
properties: properties:
instances: 1 instances: 1
# Establish a unidirectional link to the messaging capability provider (powered by NATS), # Establish a unidirectional link to the messaging capability provider (powered by NATS),
# so the `echo` component can make use of messaging interface functionality # so the `echo` component can make use of messaging interface functionality
# (i.e. making interacting with the messaging system, in this case NATS) # (i.e. making interacting with the messaging system, in this case NATS)
- type: link - type: link
properties: properties:
target: nats target: nats
namespace: wasmcloud namespace: wasmcloud
package: messaging package: messaging
interfaces: [consumer] interfaces: [consumer]
# Add a capability provider that implements `wasmcloud:messaging` using NATS # Add a capability provider that implements `wasmcloud:messaging` using NATS
- name: nats - name: nats
type: capability type: capability
properties: properties:
image: ghcr.io/wasmcloud/messaging-nats:0.23.1 image: ghcr.io/wasmcloud/messaging-nats:0.23.1
## To configure OTEL integration for this provider specifically, uncomment the lines below ## To configure OTEL integration for this provider specifically, uncomment the lines below
# config: # config:
# - name: otel # - name: otel
# properties: # properties:
# otel_exporter_otlp_endpoint: "http://all-in-one:4318" # otel_exporter_otlp_endpoint: "http://all-in-one:4318"
# otel_exporter_otlp_traces_endpoint: "http://traces-backend/v1/traces" # otel_exporter_otlp_traces_endpoint: "http://traces-backend/v1/traces"
# otel_exporter_otlp_metrics_endpoint: "http://metrics-backend/v1/metrics" # otel_exporter_otlp_metrics_endpoint: "http://metrics-backend/v1/metrics"
# otel_exporter_otlp_logs_endpoint: "http://logs-backend/v1/logs" # otel_exporter_otlp_logs_endpoint: "http://logs-backend/v1/logs"
traits: traits:
# Since the `nats` capability provider calls an component to handle messages # Since the `nats` capability provider calls an component to handle messages
# coming over subscriptions, this provider needs a unidirectional link to the # coming over subscriptions, this provider needs a unidirectional link to the
# component that wil be called. # component that wil be called.
# #
# Here we link the `nats` provider (the "source"), to the `echo` component (the "target"), # Here we link the `nats` provider (the "source"), to the `echo` component (the "target"),
# so that so the provider can deliver messages to the component (by invoking the wasmcloud:messaging/handler interface) . # so that so the provider can deliver messages to the component (by invoking the wasmcloud:messaging/handler interface) .
- type: link - type: link
properties: properties:
target: echo target: echo
namespace: wasmcloud namespace: wasmcloud
package: messaging package: messaging
interfaces: [handler] interfaces: [handler]
source_config: source_config:
- name: simple-subscription - name: simple-subscription
properties: properties:
subscriptions: wasmcloud.echo subscriptions: wasmcloud.echo

28
main.go
View File

@ -1,14 +1,14 @@
//go:generate go run github.com/bytecodealliance/wasm-tools-go/cmd/wit-bindgen-go generate --world hello --out gen ./wit //go:generate go run github.com/bytecodealliance/wasm-tools-go/cmd/wit-bindgen-go generate --world hello --out gen ./wit
package main package main
import ( import (
"gitea.rebus.ninja/lore/go-nats-client/gen/wasmcloud/messaging/handler" "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasmcloud/messaging/handler"
) )
func init() { func init() {
handler.Exports.HandleMessage = handleMessage handler.Exports.HandleMessage = handleMessage
} }
// Since we don't run this program like a CLI, the `main` function is empty. Instead, // Since we don't run this program like a CLI, the `main` function is empty. Instead,
// we call the `handleRequest` function when an HTTP request is received. // we call the `handleRequest` function when an HTTP request is received.
func main() {} func main() {}

View File

@ -1,54 +1,54 @@
//go:generate go run go.wasmcloud.dev/wadge/cmd/wadge-bindgen-go //go:generate go run go.wasmcloud.dev/wadge/cmd/wadge-bindgen-go
package main package main
import ( import (
"bytes" "bytes"
"io" "io"
"log" "log"
"log/slog" "log/slog"
"net/http" "net/http"
"os" "os"
"testing" "testing"
incominghandler "go.wasmcloud.dev/component/gen/wasi/http/incoming-handler" incominghandler "go.wasmcloud.dev/component/gen/wasi/http/incoming-handler"
"go.wasmcloud.dev/wadge" "go.wasmcloud.dev/wadge"
"go.wasmcloud.dev/wadge/wadgehttp" "go.wasmcloud.dev/wadge/wadgehttp"
) )
func init() { func init() {
log.SetFlags(0) log.SetFlags(0)
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{ slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
Level: slog.LevelDebug, ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { Level: slog.LevelDebug, ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
if a.Key == slog.TimeKey { if a.Key == slog.TimeKey {
return slog.Attr{} return slog.Attr{}
} }
return a return a
}, },
}))) })))
} }
func TestIncomingHandler(t *testing.T) { func TestIncomingHandler(t *testing.T) {
wadge.RunTest(t, func() { wadge.RunTest(t, func() {
req, err := http.NewRequest("", "/", nil) req, err := http.NewRequest("", "/", nil)
if err != nil { if err != nil {
t.Fatalf("failed to create new HTTP request: %s", err) t.Fatalf("failed to create new HTTP request: %s", err)
} }
resp, err := wadgehttp.HandleIncomingRequest(incominghandler.Exports.Handle, req) resp, err := wadgehttp.HandleIncomingRequest(incominghandler.Exports.Handle, req)
if err != nil { if err != nil {
t.Fatalf("failed to handle incoming HTTP request: %s", err) t.Fatalf("failed to handle incoming HTTP request: %s", err)
} }
if want, got := http.StatusOK, resp.StatusCode; want != got { if want, got := http.StatusOK, resp.StatusCode; want != got {
t.Fatalf("unexpected status code: want %d, got %d", want, got) t.Fatalf("unexpected status code: want %d, got %d", want, got)
} }
buf, err := io.ReadAll(resp.Body) buf, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
t.Fatalf("failed to read HTTP response body: %s", err) t.Fatalf("failed to read HTTP response body: %s", err)
} }
defer resp.Body.Close() defer resp.Body.Close()
if want, got := []byte("Hello from Go!\n"), buf; !bytes.Equal(want, got) { if want, got := []byte("Hello from Go!\n"), buf; !bytes.Equal(want, got) {
t.Fatalf("unexpected response body: want %q, got %q", want, got) t.Fatalf("unexpected response body: want %q, got %q", want, got)
} }
}) })
} }

View File

@ -1,44 +1,44 @@
package main package main
import ( import (
"github.com/bytecodealliance/wasm-tools-go/cm" "github.com/bytecodealliance/wasm-tools-go/cm"
"gitea.rebus.ninja/lore/go-nats-client/gen/wasmcloud/messaging/consumer" "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasmcloud/messaging/consumer"
"gitea.rebus.ninja/lore/go-nats-client/gen/wasmcloud/messaging/types" "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasmcloud/messaging/types"
logger "gitea.rebus.ninja/lore/go-nats-client/gen/wasi/logging/logging" logger "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/logging/logging"
//config "gitea.rebus.ninja/lore/go-nats-client/gen/wasi/config/runtime" //config "gitea.rebus.ninja/lore/go-nats-client/gen/wasi/config/runtime"
) )
type messagingConsumerAdapter struct { type messagingConsumerAdapter struct {
Publish func(msg types.BrokerMessage) (result cm.Result[string, struct{}, string]) Publish func(msg types.BrokerMessage) (result cm.Result[string, struct{}, string])
} }
// NOTE(lxf): this is overridden in tests // NOTE(lxf): this is overridden in tests
var messagingConsumer = &messagingConsumerAdapter{ var messagingConsumer = &messagingConsumerAdapter{
Publish: consumer.Publish, Publish: consumer.Publish,
} }
func handleMessage(msg types.BrokerMessage) cm.Result[string, struct{}, string] { func handleMessage(msg types.BrokerMessage) cm.Result[string, struct{}, string] {
logger.Log(logger.LevelInfo,"MessageHandler", "Received message on subject" + msg.Subject) logger.Log(logger.LevelInfo,"MessageHandler", "Received message on subject" + msg.Subject)
// TODO implement the logic to get the destination topic from the config // TODO implement the logic to get the destination topic from the config
// dest_topic := config.GetAll() // dest_topic := config.GetAll()
dest_topic := msg.Subject + ".reply" dest_topic := msg.Subject + ".reply"
// TASK // TASK
// Send reply // Send reply
reply := types.BrokerMessage{ reply := types.BrokerMessage{
Subject: dest_topic, Subject: dest_topic,
Body: msg.Body, Body: msg.Body,
ReplyTo: cm.None[string](), ReplyTo: cm.None[string](),
} }
res := messagingConsumer.Publish(reply) res := messagingConsumer.Publish(reply)
if res.IsErr() { if res.IsErr() {
logger.Log(logger.LevelError, "MessageHandler", "Failed to send reply, error: " + *res.Err()) logger.Log(logger.LevelError, "MessageHandler", "Failed to send reply, error: " + *res.Err())
return res return res
} }
return cm.OK[cm.Result[string, struct{}, string]](struct{}{}) return cm.OK[cm.Result[string, struct{}, string]](struct{}{})
} }

View File

@ -1,8 +1,8 @@
//go:build tools //go:build tools
package main package main
import ( import (
_ "github.com/bytecodealliance/wasm-tools-go/cmd/wit-bindgen-go" _ "github.com/bytecodealliance/wasm-tools-go/cmd/wit-bindgen-go"
_ "go.wasmcloud.dev/wadge/cmd/wadge-bindgen-go" _ "go.wasmcloud.dev/wadge/cmd/wadge-bindgen-go"
) )

View File

@ -2,15 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 1 version = 1
[[packages]]
name = "wasi:config"
registry = "wasi.dev"
[[packages.versions]]
requirement = "=0.2.0-draft"
version = "0.2.0-draft"
digest = "sha256:aa2d36d0843999edad80a13bf22f4529277f7b6012429f8a5d1f9499f3793c1a"
[[packages]] [[packages]]
name = "wasi:logging" name = "wasi:logging"
registry = "wasi.dev" registry = "wasi.dev"

View File

@ -1,13 +1,13 @@
name = "go_nats_client" name = "go_nats_client"
language = "tinygo" language = "tinygo"
type = "component" type = "component"
version = "1.0.0" version = "1.0.0"
[component] [component]
wit_world = "hello" wit_world = "hello"
wasm_target = "wasm32-wasip2" wasm_target = "wasm32-wasip2"
destination = "build/go_nats_client_s.wasm" destination = "build/go_nats_client_s.wasm"
[registry] [registry]
url = "gitea.rebus.ninja/lore" url = "gitea.rebus.ninja/lore"
credentials = "./creds.json" credentials = "./creds.json"

View File

@ -1,9 +1,9 @@
package wasmcloud:hello; package wasmcloud:hello;
world hello { world hello {
include wasmcloud:component-go/imports@0.1.0; include wasmcloud:component-go/imports@0.1.0;
export wasmcloud:messaging/handler@0.2.0; export wasmcloud:messaging/handler@0.2.0;
import wasmcloud:messaging/consumer@0.2.0; import wasmcloud:messaging/consumer@0.2.0;
import wasi:logging/logging@0.1.0-draft; import wasi:logging/logging@0.1.0-draft;
} }