faust icon indicating copy to clipboard operation
faust copied to clipboard

Could you please extend the setting of the webserver to pass parameters?

Open cmartmos opened this issue 2 years ago • 1 comments

Checklist

  • [X] I have included information about relevant versions
  • [X] I have verified that the issue persists when using the master branch of Faust.

Steps to reproduce

I am required to pass some parameters to the aiohttp application directly (e.g. middleware, client_max_size, ...) to extend the worker API. However, it's not possible in the actual implementation of the aiohttp driver.

Could you please extend the setting or the aiohttp driver to overcome this limitation?

Expected behavior

Support for web server parameters

Actual behavior

Not supported

Full traceback

# faust/web/drivers/aiohttp.py

class Web(base.Web):
    
    def __init__(self, app: AppT, **kwargs: Any) -> None:
        super().__init__(app, **kwargs)
        
        self.web_app: Application = Application()   # <------- EXTEND WITH KWARGS

        self.cors_options = _prepare_cors_options(app.conf.web_cors_options or {})
        self._runner: AppRunner = AppRunner(self.web_app, access_log=None)
        self._transport_handlers = {
            "tcp": self._new_transport_tcp,
            "unix": self._new_transport_unix,
        }

Versions

  • Python version: 3.10
  • Faust version: 0.10.16
  • Operating system: Ubuntu

cmartmos avatar Oct 05 '23 21:10 cmartmos

This is not that easy as we do run all the components as mode.Service instances. The first line in __init__ does exactly this, and the aiohttp.Application kwargs wouldn't be allowed in mode.Service.

What we could do though is to allow web_driver_args params in creation that could then be thrown into this.

dada-engineer avatar Oct 26 '23 08:10 dada-engineer