Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/olivere/taskqueue

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/olivere/taskqueue

  • v0.0.0-20160422152251-40ad89c8eb4b
  • Source
  • Go
  • Socket score

Version published
Created
Source

Taskqueue

This is just an experiment and not ready for production.

Taskqueue manages running and scheduling tasks (think Sidekiq or Resque).

Build Status Godoc license

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:

// Create a Redis-based backend, namespaced with "taskqueue_example"
store := taskqueue.NewRedisStore("localhost:6379", "taskqueue_example", "", 0)

// Create a manager with the Redis store. See source for more options.
m := taskqueue.New(taskqueue.SetStore(store))

// Register one or more topics and their processor
m.Register("clicks", func(args ...interface{}) error {
	// Handle "clicks" topic
})

// Start the manager
err := m.Start()
if err != nil {
	panic(err)
}

// Enqueue a task: It'll be added to the input queue and processed eventually
err = m.Enqueue(&taskqueue.Task{Topic: "clicks", Args: []interface{}{640, 480}})
if err != nil {
	panic(err)
}

...

// Stop the manager, either via Close (which stops immediately)
// or CloseWithTimeout (which gracefully waits until either all working
// tasks are completed or a timeout is reached)
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.

Screenshot

License

MIT License. See LICENSE file for details.

FAQs

Package last updated on 22 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc