https://github.com/simbiose/puraki
a simple and basic workers manager
https://github.com/simbiose/puraki
Last synced: about 1 hour ago
JSON representation
a simple and basic workers manager
- Host: GitHub
- URL: https://github.com/simbiose/puraki
- Owner: simbiose
- Created: 2013-11-14T22:11:27.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-11-24T04:31:00.000Z (over 12 years ago)
- Last Synced: 2025-06-30T16:51:02.460Z (about 1 year ago)
- Language: Lua
- Size: 117 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# summary
puraki is a worker(s) manager written in pure [Lua](http://www.lua.org/) on top of [Luvit](http://luvit.io/).
# WTF puraki means?
puraki means "to work" in [nheengatu](http://en.wikipedia.org/wiki/Nheengatu_language)
# help and support
please fill an issue or help it doing a clone and then a pull request
# license
[BEER-WARE](http://en.wikipedia.org/wiki/Beerware), see source
# basic usage
```lua
local worker, set_timeout =
require('puraki').new(), require('timer').setTimeout
worker.parallel = 20
worker.interval = 1000
-- each task is a closure, configure metadata, return a task to do, ...
worker:task(
function(this, meta)
meta.ttl = 0
meta.times = 0
local function task(metadata)
metadata.times = metadata.times + 1
p(metadata.task, metadata.times)
return (metadata.times > metadata.task)
end
return task
end)
worker:run()
set_timeout(2000, function()
p('stop queue')
worker:stop()
end)
set_timeout(4000, function()
p('resume queue')
worker:resume()
end)
```
# test
... in progress
# TODO
+ "kill" coroutines when idle, simulate error
+ create a test suite
+ create a rockspec
+ create a wiki?
% November 16th, 2013 -03 GMT