15 releases (8 breaking)

0.8.2 Aug 6, 2024
0.8.1 Jul 10, 2024
0.7.1 Jun 28, 2024
0.7.0 Sep 6, 2023
0.1.1-alpha.1 Jun 28, 2020

#946 in Network programming

MIT license

79KB
1.5K SLoC

haproxy-api

Latest Version API Documentation

haproxy-api exposes HAProxy 2.8+ 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.

Async support

Asynchronous mode is supported using Tokio runtime. The HAProxy runtime is fully integrated with Tokio runtime using HAProxy queueing system and auxiliary tcp listener for async tasks readiness notifications.

A multi-threaded tokio runtime is automatically started when the first async function is executed.

Please check the async_serve_file example to see how to serve files asynchronously.

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–11MB
~131K SLoC