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

Download history 23/week @ 2023-12-31 2/week @ 2024-01-07 38/week @ 2024-01-14 5/week @ 2024-01-21 38/week @ 2024-02-18 59/week @ 2024-02-25 124/week @ 2024-03-03 105/week @ 2024-03-10 19/week @ 2024-03-17 13/week @ 2024-03-24 117/week @ 2024-03-31 90/week @ 2024-04-07 155/week @ 2024-04-14

376 downloads per month

MIT license

65KB
1.5K SLoC

haproxy-api

Latest Version API Documentation

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