tetratelabs / Proxy Wasm Go Sdk
Licence: apache-2.0
Go SDK for WebAssembly-based Envoy extensions
Stars: ✭ 137
Programming Languages
go
31211 projects - #10 most used programming language
Projects that are alternatives of or similar to Proxy Wasm Go Sdk
Proxy Wasm Rust Sdk
WebAssembly for Proxies (Rust SDK)
Stars: ✭ 137 (+0%)
Mutual labels: proxy, webassembly, wasm, envoy
Proxy Wasm Cpp Sdk
WebAssembly for Proxies (C++ SDK)
Stars: ✭ 55 (-59.85%)
Mutual labels: proxy, webassembly, wasm, envoy
Spec
WebAssembly for Proxies (ABI specification)
Stars: ✭ 150 (+9.49%)
Mutual labels: proxy, webassembly, wasm, envoy
Awesome Wasm Tools
😎 A curated list of awesome, language-agnostic WebAssembly tools
Stars: ✭ 139 (+1.46%)
Mutual labels: webassembly, wasm
Dcmjs
dcmjs is a javascript cross-compile of dcmtk (dcmtk.org).
Stars: ✭ 92 (-32.85%)
Mutual labels: webassembly, wasm
Stork
🔎 Impossibly fast web search, made for static sites.
Stars: ✭ 1,983 (+1347.45%)
Mutual labels: wasm, webassembly
As Wasi
An AssemblyScript API layer for WASI system calls.
Stars: ✭ 135 (-1.46%)
Mutual labels: webassembly, wasm
Percy
Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
Stars: ✭ 1,856 (+1254.74%)
Mutual labels: webassembly, wasm
Made With Webassembly
A showcase of awesome production applications, side projects, and use cases made with WebAssembly (Wasm). 👷
Stars: ✭ 132 (-3.65%)
Mutual labels: webassembly, wasm
Telegram React
Experimental Telegram web client with tdlib, webassembly and react js under the hood
Stars: ✭ 1,332 (+872.26%)
Mutual labels: webassembly, wasm
Lunatic
Lunatic is an Erlang-inspired runtime for WebAssembly
Stars: ✭ 2,074 (+1413.87%)
Mutual labels: webassembly, wasm
D3 Wasm Force
A re-implementation of d3-force with WebAssembly.
Stars: ✭ 93 (-32.12%)
Mutual labels: webassembly, wasm
Jsnet
Javascript/WebAssembly deep learning library for MLPs and convolutional neural networks
Stars: ✭ 126 (-8.03%)
Mutual labels: webassembly, wasm
Blazormaterial
Blazor components implementing Google's Material components for web - https://material.io/components/web
Stars: ✭ 136 (-0.73%)
Mutual labels: webassembly, wasm
Emscripten Docker
Docker image with Emscripten to compile ASM.js and WebAssembly
Stars: ✭ 92 (-32.85%)
Mutual labels: webassembly, wasm
Go SDK for WebAssembly-based Envoy extensions
This project is in its early stage, and the API is likely to change and not stable.
The Go sdk for proxy-wasm, enabling developers to write Envoy extensions in Go.
proxy-wasm-go-sdk is powered by TinyGo and does not support the official Go compiler.
import (
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types"
)
var counter proxywasm.MetricCounter
type metricRootContext struct { proxywasm.DefaultRootContext }
func (ctx *metricRootContext) OnVMStart(int) types.OnVMStartStatus {
// initialize the metric
counter = proxywasm.DefineCounterMetric("proxy_wasm_go.request_counter")
return types.OnVMStartStatusOK
}
type metricHttpContext struct { proxywasm.DefaultHttpContext }
func (ctx *metricHttpContext) OnHttpRequestHeaders(int, bool) types.Action {
// increment the request counter when we receive request headers
counter.Increment(1)
return types.ActionContinue
}
requirements
proxy-wasm-go-sdk depends on TinyGo's WASI (WebAssembly System Interface) target which is introduced in v0.16.0.
Please follow the official instruction here.
compatible ABI / Envoy builds (verified on CI)
proxy-wasm-go-sdk | proxy-wasm ABI version | istio/proxyv2 | Envoy upstream |
---|---|---|---|
main | 0.2.0 | 1.8.1+ | 1.17.x |
v0.1.0 | 0.2.0 | 1.8.{1,2,3,4}, 1.9.{0,1} | 1.17.{0,1} |
run examples
build:
make build.examples # build all examples
make build.examples.docker # in docker
make build.example name=helloworld # build a specific example
make build.example.docker name=helloworld # in docker
run:
make run name=helloworld
sdk development
make test # run local tests without running envoy processes
## requires you to have Envoy binary locally
make test.e2e # run e2e tests
## requires you to have Envoy binary locally
make test.e2e.single name=helloworld # run e2e tests
limitations and considerations
- Some of existing libraries are not available (importable but runtime panic / non-importable)
- There are several reasons for this:
- TinyGo's WASI target does not support some of syscall: For example, we cannot import
crypto/rand
package. - TinyGo does not implement all of reflect package(examples).
- proxy-wasm-cpp-host has not supported some of WASI APIs yet (see the supported functions).
- TinyGo's WASI target does not support some of syscall: For example, we cannot import
- These issues will be mitigated as TinyGo and proxy-wasm-cpp-host evolve.
- There are several reasons for this:
- There's performance overhead of using Go/TinyGo due to GC
-
runtime.GC
is called whenever the heap runs out (see 1, 2). - TinyGo allows us to disable GC, but we cannot do that since we need to use maps (implicitly causes allocation) for saving the plugin's state.
- Theoretically, we can implement our own GC algorithms tailored for proxy-wasm through
alloc(uintptr)
interface with-gc=none
option. This is the future TODO.
-
-
recover
is not implemented in TinyGo, and there's no way to prevent the WASM virtual machine from aborting. - Goroutine support
- In Tinygo, Goroutine is implmeneted through LLVM's coroutine (see this blog post).
- In Envoy, WASM modules are run in the event driven manner, and therefore the "scheduler" is not executed once the main function exits.
That means you cannot have the expected behavior of Goroutine as in ordinary host environments.
- The question "How to deal with Goroutine in a thread local WASM VM executed in the event drive manner" has yet to be answered.
- We strongly recommend that you implement the
OnTick
function for any asynchronous task instead of using Goroutine. - The scheduler can be disabled with
-scheduler=none
option of TinyGo.
references
- https://github.com/proxy-wasm/spec
- https://github.com/proxy-wasm/proxy-wasm-cpp-sdk
- https://github.com/proxy-wasm/proxy-wasm-rust-sdk
- https://github.com/tetratelabs/envoy-wasm-rust-sdk
- https://tinygo.org/
Special thanks to TinyGo folks:)
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].