lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi list,

I would like to present one of my recent projects.

This is not actually a new piece of software, but it has never been announced here (I only tried /r/lua, where, as I understand it, only a really small fraction of Lua developers is present), so better late than never.

---

Summary:

Socket-like buffer objects suitable for data stream processing, unit testing, and so on.

Links:

* Homepage: https://github.com/un-def/lua-buffet
* Examples: https://github.com/un-def/lua-buffet/tree/master/examples/
* Luarocks: https://luarocks.org/modules/undef/lua-buffet
* OPM: https://opm.openresty.org/package/un-def/lua-buffet/

Description:

A buffet is an object that has the same interface as socket objects in the popular Lua libraries LuaSocket and Lua Nginx Module but doesn't do any real network communication. Instead the network stack the buffet receives data from an arbitrary source. The data source can be a string, a table of strings or an iterator function producing strings.

The buffet works in a streaming fashion. That is, the buffet doesn't try to read and store internally the whole source data at once but reads as little as possible and only when necessary. That means that the buffet can be efficiently used as a proxy for sources of unlimited amounts of data such as real sockets or file I/O readers.

Another possible use is unit testing where the buffet can be used as a mock object instead of the real socket object.

Fun fact: the word "buffet" is a portmanteau of "buffer" and "socket".

Status:

As of version 0.2.0, all of ngx.socket.tcp methods are implemented/mocked. LuaSocket TCP interface is not implemented but ngx.socket.tcp implementation should be compatible. UDP interfaces are not implemented. All missing interfaces can be easily added if there is a need.

License:

The MIT License.