Goqueue

Khalil Claybon
2 min readAug 24, 2017

--

A simple worker-job queue for your Golang applications

Sometimes it may be useful to perform some type of processing asynchronously to not impede the performance of your application server. For example you may be doing some CPU intensive encryption task, archiving some data, or uploading some files to a server. The benefit of doing these types of tasks asynchronously is saving system resources and keeping your application alive. You can accomplish this in many ways using Golang, one of the most simple ways is to use workers, jobs and a queue. Goqueue is a Golang package that attempts to bootstrap everything for you to get you Go-ing (pun intended) with workers and jobs quickly.

Goqueue Jobs are simple functions that conform to the definition of a function on the Application interface inside the package

Now in your main function create a new Goqueue job, redis connection info and create a new app

Once you start your queue workers will be spawned in the background and start polling Redis for data

You can specify polling (seconds) frequency and number of workers for each job

Enqueueing data is done by calling the Enqueue function on your created app

Now we have a simple queue called my-new-queue, inside our application we can queue up some strings and our workers will process these strings off the queue by executing the perform function that we specified.

A more advanced example with a web server is here

Please submit feature requests and give some feed back :)

--

--