lua-eco(中文)
Lua-eco is a Lua interpreter with a built-in event loop for scheduling lightweight coroutines automatically, enabling efficient concurrency in Lua. Build high-performance, scalable applications.
Lua-eco also provides some modules for you to build applications quickly:
log
: Provides logging functionality for Lua-eco applications, allowing you to log messages at different severity levels and output them to various destinations.time
: Provides a Lua interface, allowing you to get current time, sleeping, performing timer operations.file
: Provides a Lua interface, allowing you to read and write files, traverse directory and perform other file-related operations.sys
: Provides access to various system-level functionality, such as process id, system information, and allows you to execute shell commands while obtaining their exit status as well as their standard output and standard error output.socket
: Provides a low-level network socket interface for Lua-eco applications, allowing you to create and manage network connections. Includes tcp, tcp6, udp, udp6 and unix.ssl
: Provides SSL/TLS support for Lua-eco applications, allowing you to establish secure connections to remote servers.http/https
: Provides a HTTP client and server implementation for Lua-eco applications.websocket
: Provides a WebSocket client and server implementation for Lua-eco applications, allowing you to build real-time web applications.mqtt
: Provides an implementation of the MQTT 3.1.1 protocol for Lua-eco applications.dns
: Provides a DNS client implementation for Lua-eco applications, allowing you to perform DNS lookups and resolve domain names.ubus
: Provides a Lua interface to the ubus system in OpenWrt, allowing you to interact with system services and daemons.sync
: Provides operations for synchronization between coroutines.channel
: Provides a mechanism for communication between coroutines by sending and receiving values.netlink
: Provides operations for inter-process communication (IPC) between both the kernel and userspace processes.nl80211
: Show/manipulate wireless devices and their configuration.termios
: Bind unix API for terminal/serial I/O.ssh
: Bind libssh2.packet
: For low-level packet construction and parsing.
Would you like to try it? Kinda interesting.
#!/usr/bin/env eco
local time = require 'eco.time'
eco.run(function(name)
while true do
print(time.now(), name, eco.id())
time.sleep(1.0)
end
end, 'eco1')
eco.run(function(name)
while true do
print(time.now(), name, eco.id())
time.sleep(2.0)
end
end, 'eco2')
- libev - A full-featured and high-performance event loop
sudo apt install -y liblua5.3-dev libev-dev libssl-dev libmosquitto-dev
git clone --recursive https://github.com/zhaojh329/lua-eco.git
cd lua-eco && mkdir build && cd build
cmake .. && sudo make install
Languages --->
Lua --->
-*- lua-eco............... A Lua interpreter with a built-in libev event loop
-*- lua-eco-base64................................ base64 support for lua-eco
-*- lua-eco-dns...................................... dns support for lua-eco
-*- lua-eco-file.............................. file utils support for lua-eco
-*- lua-eco-http.............................. http/https support for lua-eco
-*- lua-eco-log................................ log utils support for lua-eco
<*> lua-eco-mqtt.................................... mqtt support for lua-eco
<*> lua-eco-network.............................. network support for lua-eco
-*- lua-eco-sha1.................................... sha1 support for lua-eco
-*- lua-eco-socket................................ socket support for lua-eco
-*- lua-eco-ssl...................................... ssl support for lua-eco
SSL Library (mbedTLS) --->
-*- lua-eco-sys.............................. system utils support for lua-eco
<*> lua-eco-termios............................... termios support for lua-eco
-*- lua-eco-ubus..................................... ubus support for lua-eco
<*> lua-eco-websocket........................... websocket support for lua-eco
<*> lua-eco-netlink............................... netlink support for lua-eco
<*> lua-eco-nl80211............................... nl80211 support for lua-eco
<*> lua-eco-packet................................. packet support for lua-eco