Migrate WASM Go Plugins to New SDK and Go 1.24 (#2532)

This commit is contained in:
xingpiaoliang
2025-07-11 10:43:00 +08:00
committed by GitHub
parent 9a45f07972
commit 081ab6ee8d
274 changed files with 2073 additions and 2165 deletions

View File

@@ -24,9 +24,10 @@ import (
"api-workflow/utils"
. "api-workflow/workflow"
"github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper"
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm"
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types"
"github.com/higress-group/wasm-go/pkg/log"
"github.com/higress-group/wasm-go/pkg/wrapper"
"github.com/tidwall/gjson"
)
@@ -36,7 +37,9 @@ const (
DefaultTimeout uint32 = 5000
)
func main() {
func main() {}
func init() {
wrapper.SetCtx(
"api-workflow",
wrapper.ParseConfigBy(parseConfig),
@@ -44,7 +47,7 @@ func main() {
)
}
func parseConfig(json gjson.Result, c *PluginConfig, log wrapper.Log) error {
func parseConfig(json gjson.Result, c *PluginConfig, log log.Log) error {
edges := make([]Edge, 0)
nodes := make(map[string]Node)
@@ -174,7 +177,7 @@ func initWorkflowExecStatus(config *PluginConfig) (map[string]int, error) {
return result, nil
}
func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action {
func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action {
initHeader := make([][2]string, 0)
// 初始化运行状态
@@ -199,7 +202,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte
}
// 放入符合条件的edge
func recursive(edge Edge, headers [][2]string, body []byte, depth uint32, config PluginConfig, log wrapper.Log, ctx wrapper.HttpContext) error {
func recursive(edge Edge, headers [][2]string, body []byte, depth uint32, config PluginConfig, log log.Log, ctx wrapper.HttpContext) error {
var err error
// 防止递归次数太多