Taskqueue
This is just an experiment and not ready for production.
Taskqueue manages running and scheduling tasks (think Sidekiq or Resque).
Prerequisites
Redis is currently only persistent storage backend. So you must have Redis
installed.
Getting started
Get the repository with go get github.com/olivere/taskqueue
.
Example:
store := taskqueue.NewRedisStore("localhost:6379", "taskqueue_example", "", 0)
m := taskqueue.New(taskqueue.SetStore(store))
m.Register("clicks", func(args ...interface{}) error {
})
err := m.Start()
if err != nil {
panic(err)
}
err = m.Enqueue(&taskqueue.Task{Topic: "clicks", Args: []interface{}{640, 480}})
if err != nil {
panic(err)
}
...
err = m.CloseWithTimeout(15 * time.Second)
if err != nil {
panic(err)
}
See the tests for more details on using taskqueue.
Tests and Web UI
Ensure the tests succeed with go test
. You may have to install dependencies.
Run an end-to-end test with go run e2e/main.go
. It simulates a real worker.
Play with the options: go run e2e/main.go -h
.
While running the end-to-end tests, open up a second console and run
cd ui && go run main.go
. Then direct your web browser to 127.0.0.1:12345
.
License
MIT License. See LICENSE file for details.