Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Middleware API #5228

Open
anlumo opened this issue Nov 7, 2024 · 0 comments
Open

Improved Middleware API #5228

anlumo opened this issue Nov 7, 2024 · 0 comments
Labels
🎉 enhancement New feature!

Comments

@anlumo
Copy link

anlumo commented Nov 7, 2024

Motivation

Currently, the middleware API supplies two hooks:

  • per-module initialization
  • per-function initialization

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.

@anlumo anlumo added the 🎉 enhancement New feature! label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature!
Projects
None yet
Development

No branches or pull requests

1 participant