Improved Middleware API #5228
Labels
🎉 enhancement
New feature!
📦 lib-middlewares
About wasmer-middlewares
🕵️ needs investigation
The issue/PR needs further investigation
Motivation
Currently, the middleware API supplies two hooks:
Middlewares are also attached to engines (rather than modules or instances).
However, there is no connection between those two. This means that when a middleware encounters a new function, it does not know which module this function belongs to. Since parallel compilation is possible, it's also not possible to assume that the last module initialization belongs to the current function initialization (I guess).
The only middleware currently available is the metering example. In order to cope with this API, the middleware is restricted to handle a single module per engine via runtime check (with a panic).
Proposed solution
Either attach middlewares to modules or instances rather than the whole engine, or supply the module id to the per-function initialization.
Additional context
It would be good to have other middleware examples in order to demonstrate the additional possibilities of this API. Right now this seems only to be good for metering, but maybe I'm missing something.
The text was updated successfully, but these errors were encountered: