GithubHelp home page GithubHelp logo

zhaojh329 / lua-eco Goto Github PK

View Code? Open in Web Editor NEW
65.0 4.0 12.0 807 KB

🐛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.

License: MIT License

CMake 0.89% C 75.28% Lua 23.83%
lua coroutine libev socket ssl dns http https mqtt ubus

lua-eco's Introduction

lua-eco(中文)

license PRs Welcome Issue Welcome Release Version Build Status visitors

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.
  • 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.

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')

Requirements

  • libev - A full-featured and high-performance event loop

Build

Ubuntu

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

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-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's People

Contributors

gl-zhaojianhui avatar lancersky avatar zhanglin6 avatar zhaojh329 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lua-eco's Issues

Problem with compilation

Environment

  • arch: x86_64
  • os: GNU / Linux Debian
  • version: testing

Description

It fails to compile:

/home/stefanos/development/sources/lua-eco/eco.c: In function ‘eco_resume’:
/home/stefanos/development/sources/lua-eco/eco.c:100:18: error: too few arguments to function ‘lua_resume’
  100 |     int status = lua_resume(co, L, narg);
      |                  ^~~~~~~~~~
In file included from /usr/include/lua5.4/lualib.h:11,
                 from /home/stefanos/development/sources/lua-eco/eco.c:26:
/usr/include/lua5.4/lua.h:300:15: note: declared here
  300 | LUA_API int  (lua_resume)     (lua_State *L, lua_State *from, int narg,
      |               ^~~~~~~~~~
make[2]: *** [CMakeFiles/eco.dir/build.make:76: CMakeFiles/eco.dir/eco.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:122: CMakeFiles/eco.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Yes, the error points at Lua 5.4, but I have tested it with 5.3 and produces the same error.

Also, I get this warning during cmake ..:

CMake Warning at CMakeLists.txt:108 (message):
  Not found libubus.  Skip build eco.ubus

server.lua example no longer working because of bufio

/usr/local/lib/lua/5.3/eco/bufio.lua:239: "reader" must be a table
when running example server.lua
The c code seems to expect a number from getfd but
this happens:

    if type(reader) ~= 'table' then
        error('"reader" must be a table')
    end

/usr/local/lib/libeco.so not found

after fresh install on VPS libeco.so not found
Could -Wl,-rpath=/usr/local/lib be added at compile time please.
I know its my problem with LD_LIBRARY_PATH but if you
know it will be installed at /usr/local/lib it won't hurt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.