lua concurrency library based on libev, similar with gevent
levent is a lua concurrency networking library inspired by gevent.
Features include:
levent is licensed under MIT license.
Install lua 5.3 or newer(for lua5.2 and older, see branch lua5.2).
Clone the repository.
Post feedback and issues on the bug tracker,
Need cmake 2.8 or newer.
Modify cmake.config properly and then run:
cmake .
make
ways to build on windows, ref to blog
levent’s api is clean, to request http concurrently is as simple as below:
lua <<SCRIPT
local levent = require "levent.levent"
local http = require "levent.http"
local urls = {
"http://www.google.com",
"http://yahoo.com",
"http://example.com",
"http://qq.com",
}
function request(url)
local response, err = http.get(url)
if not response then
print(url, "error:", err)
else
print(url, response:get_code())
end
end
function main()
for _, url in ipairs(urls) do
levent.spawn(request, url)
end
end
levent.start(main)
SCRIPT
there are some tests and examples under tests
and examples
to illustrate how to use levent, you can run tests and examples from root folder of levent as below.
lua tests/test_socket.lua
lua examples/dns_mass_resolve.lua
coming soon~~
The MIT License (MIT)
Copyright © 2014 xjdrew