[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] lua-t networking, packing, etc
- From: tobias@...
- Date: Sat, 02 Dec 2017 11:18:28 +0100
I like to introduce lua-t, a general library for networking(sync/async),
binary packing etc. It had been developed originally to work with embedded
hardware and that somewhat defines it's functionality at this point. It
has, however, a lot of generally useful functionality. It's a developer
Source code (examples/tests/docs) can be found on github:
There is not luarocks package yet, currently Linux only ... it's version 0.1
The scope of available functionality:
* Networking( Sockets, Addresses, Interfaces )
* Asynchronous Event Loop (Sockets and Timers)
* Binary Packing (Byte and Bit level[signed/unsigned])
* Buffers (can be used as mutable strings, used with Sockets and Packers)
* Buffer Segments (Buffer access control)
* Unit testing (sync/async)
* Ordered Hashtable (Lua table preserving insertion order)
* Set (with all relevant union/intersection/complement/symdiff)
* HTTP Server (Uses the asynchronous event loop, Callback based)
* En/Decoding (Base64/Crc for now)
* Timer (millisecond level)
lua-t strives to be fully unit tested in itself. I'm not claiming 100% or
anything near that because it's impossible, but I like to believe it is
reasonably thorough. lua-t has it's own Unit test framework which was
inspired by nose tests.
There is a good amount of documentation. Being a developer, writing that is
not my forte. I tried to keep it updated and it is pretty detailed. Also,
I'm not a native speaker, so there is that.
The `example` folder was mainly used before the Unit test suite was
finalized. Some code in there may be pretty old and may or may not have
been updated over multiple phases of refactoring. It is still useful to
On the `pure Lua` or C vs Lua issue: The first pieces of lua-t were binary
packing and networking. That was C only. In fact the original layout of
the library was a C monolith (single .so file). That original design still
shows in some bits and pieces and there are parts of lua-t which may better
be implemented in Lua rather than in C. It's on the roadmap to change that.
But given the support for networking, asynchronous Loop, binary packing,
buffers etc, lua-t can never be a `pure Lua` library. Anyways, I think it
is a nice example how C and Lua code can live side by side and work hand in
hand in the same library.
On platform compatibility:
... Linux only for now :-) I don't have a Mac and the development for the
asynchronous loop stuff needs some attention. For Windows, it would be
possible to do that. It is set up to implement it. The asynchronous stuff
is based of redis and there is a windows port available with a license
permitting to get inspired by it. But it would be a good bunch of work.
Because of the unit test coverage it should be relatively straight forward
to test completeness of the port. Also I don't have access to ARM hardware
anymore which would be needed to test the Packer (Endianess). It is
implemented but not tested.
On why not released earlier:
I know it's considered to be bad practice to develop a large piece of
software basically in full and 'release' it when it's done. It robs the
community of the ability to have input and ultimately makes the software
less attractive. lua-t was the result of a couple of coincidences and it
would have been detrimental to it's primary use to release it in it's hot
phase when I was using it to help with my day job. At the time it was not
very organized and it was a VERY moving target. The now released version is
an attempt to put it into a more manageable format which very well may serve
as a starting point for a discussion with users who like to use it. It's
just a little big to digest it as a whole :-P.
On overlap with existing libraries:
I'm well aware that it overlaps with a whole lot of other libraries
(luasocket, Lua string.pack, lua-uv, penlight etc.). There are reasons why
I couldn't use those (first pieces of lua-t were written in 2013) and
eventually rolled my own. Also, for example, it would be impossible
(reliably) to include lua-socket and make that work with what's done in
lua-t asynchronous Loop implementation.
Any input, criticism or praise is welcome. If someone want's to tackle
Mac/Win ports please talk to me. Thanks for reading and looking at it.