12 releases (7 breaking)
0.7.0 | Sep 6, 2023 |
---|---|
0.6.0 | Nov 9, 2022 |
0.5.0 | Jun 13, 2022 |
0.4.0 | Dec 2, 2021 |
0.1.1-alpha.1 | Jun 28, 2020 |
#1121 in Network programming
376 downloads per month
65KB
1.5K
SLoC
haproxy-api
haproxy-api
exposes HAProxy 2.x Lua API to use from Rust.
In conjunction with mlua it allows to run Rust code in HAProxy as a Task/Converter/Fetcher/Service/etc.
You can extend HAProxy on a safe and efficient way beyond Lua restrictions.
Thanks to mlua, asynchronous mode is also supported and every time when requested Future is in Pending
state, haproxy-api
conviniently executes core.yield()
under the hood to return to the HAProxy scheduler.
Please check the async_serve_file
example to see how to serve files asynchronously using Tokio.
Bear in mind that asynchronous mode is not too efficient because there is no way to integrate with HAProxy scheduler (current behavior is more close to busy polling).
Usage
Please check our examples:
- async serve file - How to serve files asynchronously
- brotli - How to add brotli compression to HAProxy using filters API
- simple - How to register fetches and converters
Restrictions
Executing HAProxy functions that require yielding is not supported (eg: core.sleep
), and these functionality is not exposed.
Although you can run them from Lua or using register_lua_*
set of functions.
License
This project is licensed under the MIT license
Dependencies
~2.7–4MB
~76K SLoC