sozu icon indicating copy to clipboard operation
sozu copied to clipboard

WebAssembly plugins

Open Geal opened this issue 4 years ago • 1 comments

I would like to introduce wasm plugins at these points:

  • main process, for small tasks that can change the configuration (talking to a service discovery, etc)
  • routing filter, deciding on different routes to applications than what the main router would do
  • request and response filters: editing header, body, overriding responses, etc

We can get inspiration from Envoy's wasm filters: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/wasm/v3/wasm.proto

Geal avatar Jul 29 '21 09:07 Geal

After using and being part of the Envoy Wasm experiment I'd strongly encourage you to not focus on Wasm middleware but rather dynamic module support so that any language that can be compiled to a shared object can be used.

As an example, see https://github.com/envoyproxy/envoy/issues/35420. There is an effort underway in Envoy which dates way back to 2017 (https://github.com/envoyproxy/envoy/issues/2053) to add loadable modules. Work is underway to start this with https://github.com/envoyproxy/envoy/pull/35550 and is based on https://github.com/mathetake/envoy-dynamic-modules. The ABI is simple and straightforward and the SDK directory contains examples for both Go and Rust (https://github.com/mathetake/envoy-dynamic-modules/tree/main/source/extensions/dynamic_modules/sdk).

Going in the direction of loadable modules offers flexibility and simplicity and building a loadable module which brings in a Wasm runtime becomes relatively simple. It also allows for easy customization of the proxy through an extension pattern which means that the proxy can be extended without polluting the codebase with extensions of various quality.

marc-barry avatar Aug 23 '24 03:08 marc-barry