]> git.ipfire.org Git - thirdparty/haproxy.git/commit
EXAMPLES: add "games.cfg" and an example game in Lua
authorWilly Tarreau <w@1wt.eu>
Tue, 1 Apr 2025 07:10:00 +0000 (09:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 1 Apr 2025 07:10:00 +0000 (09:10 +0200)
commited1d4807da0bbea2e6b426d35347af45f4e7cd54
tree65713ef4c22bf26484a6b71d41c9b011f80cc525
parent2c779f3938d49fbb0955e972b4f494cdadbef8c1
EXAMPLES: add "games.cfg" and an example game in Lua

The purpose is mainly to exhibit certain limitations that come with such
less common programming models, to show users how to program interactive
tools in Lua, and how to connect interactively.

Other use cases that could be envisioned are "top" and various monitoring
utilities, with sliding graphs etc. Lua is particularly attractive for
this usage, easy to program, well known from most AI tools (including its
integration into haproxy), making such programs very quick to obtain in
their basic form, and to improve later.

A very limited example game is provided, following the principle of a
very popular one, where the player must compose lines from falling
pieces. It quickly revealed the need to the ability to enforce a timeout
to applet:receive(). Other identified limitations include the difficulty
from the Lua side to monitor multiple events at once, but it seems that
callbacks and/or event dispatchers would be useful here.

At the moment the CLI is not workable (it interactivity was broken in 2.9
when line buffering was adopted), though it was verified that it works
with older releases.

The command needed to connect to the game is displayed as a notice message
during boot.
examples/games.cfg [new file with mode: 0644]
examples/lua/trisdemo.lua [new file with mode: 0644]