added destination topic to config
This commit is contained in:
parent
ac9a119eb5
commit
cb51ae31e7
@ -5,6 +5,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
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__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"
|
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"
|
github_com__bytecodealliance__wasm___tools___go__cm "github.com/bytecodealliance/wasm-tools-go/cm"
|
||||||
@ -17,6 +18,46 @@ const _ string = runtime.Compiler
|
|||||||
|
|
||||||
var _ unsafe.Pointer
|
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
|
//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) {
|
func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32) {
|
||||||
var __p runtime.Pinner
|
var __p runtime.Pinner
|
||||||
|
11
messaging.go
11
messaging.go
@ -5,6 +5,7 @@ import (
|
|||||||
"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"
|
||||||
logger "gitea.rebus.ninja/lore/go-nats-client/gen/wasi/logging/logging"
|
logger "gitea.rebus.ninja/lore/go-nats-client/gen/wasi/logging/logging"
|
||||||
|
//config "gitea.rebus.ninja/lore/go-nats-client/gen/wasi/config/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type messagingConsumerAdapter struct {
|
type messagingConsumerAdapter struct {
|
||||||
@ -20,8 +21,16 @@ 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
|
||||||
|
// dest_topic := config.GetAll()
|
||||||
|
dest_topic := msg.Subject + ".reply"
|
||||||
|
|
||||||
|
// TASK
|
||||||
|
|
||||||
|
|
||||||
|
// Send reply
|
||||||
reply := types.BrokerMessage{
|
reply := types.BrokerMessage{
|
||||||
Subject: msg.Subject + ".reply",
|
Subject: dest_topic,
|
||||||
Body: msg.Body,
|
Body: msg.Body,
|
||||||
ReplyTo: cm.None[string](),
|
ReplyTo: cm.None[string](),
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,10 @@ spec:
|
|||||||
# image: file://./build/echo_messaging_s.wasm
|
# image: file://./build/echo_messaging_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
|
||||||
|
config:
|
||||||
|
- name: nats-topic
|
||||||
|
properties:
|
||||||
|
dest-topic: wasmcloud.echo.reply
|
||||||
traits:
|
traits:
|
||||||
# Govern the spread/scheduling of the component
|
# Govern the spread/scheduling of the component
|
||||||
- type: spreadscaler
|
- type: spreadscaler
|
||||||
|
@ -2,6 +2,15 @@
|
|||||||
# 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"
|
||||||
|
Loading…
Reference in New Issue
Block a user