Skip to content

simbiose/puraki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

summary

puraki is a worker(s) manager written in pure Lua on top of Luvit.

WTF puraki means?

puraki means "to work" in nheengatu

help and support

please fill an issue or help it doing a clone and then a pull request

license

BEER-WARE, see source

basic usage

    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

About

a simple and basic workers manager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages