Comments (5)
I've noticed that, thanks. That's exactly a question for your rust example. And maybe we should consider the return value of both proxy_on_request_headers
and a.Imports.Wait()
on ABIContext.ProxyOnRequestHeaders
, instead of simply taking the return value of a.Imports.Wait()
, and ignoring proxy_on_request_headers
.
a.Imports.Wait()
is actually for async callout from the wasm module. For example, if you make a HTTP callout in your wasm module, then the go-host should launch the HTTP call, and wait for a response synchronously, and that's the Wait
function exactly do. In this case, the ActionContinue
from proxy_on_request_headers
should be ignored, since you're waiting for the response of the previous HTTP callout to make further decision.
from proxy-wasm-go-host.
Thanks for your reply. When I stress test the code, whether it uses the original wasm or my own, memory leaks will occur. Do you have any ideas about it?
from proxy-wasm-go-host.
try pprof
, may need to add the following pprof section into mosn config:
from proxy-wasm-go-host.
Thanks, I'll try it later.
from proxy-wasm-go-host.
@Taction this module is incompatible with any current version of proxy-wasm. The only thing I could get to build is an old version of 0.1.0. I would suggest working with mosn project leads to allow an alternate implementation in mosn. That or we add https://http-wasm.io/http-handler/ and leave proxy-wasm alone. Since you are an end user I think best you help drive action here. cc @taoyuanyuan
package main
import (
"strconv"
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types"
)
// build main like below with proxy-wasm-go-sdk v0.0.14 which works with
// TinyGo 0.19.0 (which works with Go 1.16).
//
// tinygo build -o main.wasm -scheduler=none -target=wasi -tags 'abi_010' --no-debug ./main.go
//
// Note: Old tooling is needed because mosn.io/proxy-wasm-go-host v2 is
// incompatible with the proxy-wasm specification.
func main() {
proxywasm.SetNewHttpContext(newHttpContext)
}
type myHttpContext struct {
// you must embed the default context so that you need not to re-implement all the methods by yourself
proxywasm.DefaultHttpContext
contextID uint32
}
func newHttpContext(rootContextID, contextID uint32) proxywasm.HttpContext {
return &myHttpContext{contextID: contextID}
}
func (ctx *myHttpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action {
key := "Wasm-Context"
err := proxywasm.SetHttpRequestHeader(key, strconv.Itoa(int(ctx.contextID)))
if err != nil {
proxywasm.LogCritical("failed to set request header: " + key)
}
return types.ActionContinue
}
from proxy-wasm-go-host.
Related Issues (10)
- BufferType extension should be support
- Imports/exports don't match expected Proxy-Wasm ABI versions. HOT 4
- go get mosn.io/proxy-wasm-go-host/proxywasm/common is failing HOT 4
- Not able to add header element. HOT 3
- Can you add the implementation and example of wazero? HOT 13
- Drop ABI v0.1.0 HOT 9
- Change example to use currently maintained ABI (0.2) HOT 1
- err: "proxy_set_buffer_bytes" is not exported in module "env"
- Add CI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proxy-wasm-go-host.