2 Star 7 Fork 2

赵建辉 / lua-eco

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

lua-eco

license PRs Welcome Issue Welcome Release Version Build Status visitors Chinese Chat

Lua-eco 是一个内置了事件循环的 Lua 解释器。它能够自动调度轻量级 Lua 协程, 从而实现在 Lua 中的高效并发。使用 Lua-eco 可以构建高性能、可扩展的应用程序。

Lua-eco 还提供了一些有用的模块,方便您快速构建应用程序:

  • log: 为 lua-eco 应用程序提供日志功能,允许您以不同的级别打印日志并将其输出到各种目的地。
  • time: 提供了一个 Lua 接口,用于获取系统时间,休眠,执行定时器操作。
  • file: 提供了一个 Lua 接口,允许您读写入文件,遍历目录以及执行其他与文件相关的操作。
  • sys: 提供了对各种系统级功能的访问,例如进程ID,系统信息,同时允许您执行shell命令并获取其退出状态以及标准输出和标准错误输出。
  • socket: 提供了一组网络套接字接口,允许您创建和管理网络连接。包括 tcp,tcp6,udp,udp6 和 unix。
  • ssl: 为 Lua-eco 应用程序提供了 SSL/TLS 支持,允许您建立与远程服务器的安全连接。
  • http/https: 为 Lua-eco 应用程序提供了 HTTP(S) 客户端和服务器实现。
  • websocket: 为 Lua-eco 应用程序提供了一个 WebSocket 客户端和服务器实现,允许您构建实时 Web 应用程序。
  • mqtt: 为 Lua-eco 应用程序提供了一个 MQTT 3.1.1 协议的实现。
  • dns: 为 Lua-eco 应用程序提供了一个 DNS 客户端实现,允许您执行 DNS 查找和解析域名。
  • ubus: 提供了一个 Lua 接口,用于 OpenWrt 中的 ubus 系统,允许您与系统服务和守护程序交互。
  • sync: 提供了协程间同步的操作。
  • netlink: 为内核和用户空间进程之间的进程间通信(IPC)提供操作。
  • nl80211: 显示/操作无线设备及其配置。
  • termios: 绑定 unix 接口用于操作终端和串口。
  • ssh: 绑定 libssh2.

想试试吗?很有趣的!

#!/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 - 高性能的事件循环库

编译

Ubuntu

sudo apt install -y liblua5.3-dev lua5.3 libev-dev libssl-dev
git clone --recursive https://github.com/zhaojh329/lua-eco.git
cd lua-eco && mkdir build && cd build
cmake .. && sudo make install

OpenWrt

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-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-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
MIT License Copyright (c) 2022 Jianhui Zhao <zhaojh329@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Lua-eco 是一个内置了事件循环的 Lua 解释器。它能够自动调度轻量级 Lua 协程, 从而实现在 Lua 中的高效并发。使用 Lua-eco 可以构建高性能、可扩展的应用程序。 展开 收起
Lua 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Lua
1
https://gitee.com/zhaojh329/lua-eco.git
git@gitee.com:zhaojh329/lua-eco.git
zhaojh329
lua-eco
lua-eco
master

搜索帮助