Task Queues in Go using Asynq
Achintya

CODE


SLIDE
Queues
Workers



Asynq is a Go library for queueing tasks and processing them asynchronously with workers.
High level overview of how Asynq works:
-
Client puts tasks on a queue
-
Server pulls tasks off queues and starts a worker goroutine for each task
-
Tasks are processed concurrently by multiple workers
REDIS
Setup a redis instance or cluster which will act as a queue. It can have different types of queues as well.
1.
ASYNQ CLIENT
Define an asynq.Client
object with the Redis URL. This object then can be used to enqueue new tasks by passing an async.Task
to its enqueue function
2.
ASYNQ SERVER
Finally, define an object asynq.Server
and set up handlers for tasks. After setting up the handlers, start up an asynq server by passing Redis url
3.


2. It will add the new welcome email task to queue.
1. Call the /start api
3. After it, it will call another API to add a training task in queue.
4. After training, the training complete email task is called via another API.
5. Finally, the training complete task is executed.
Thank You
Asqyq
By Achintya Pranshu
Asqyq
For a talk on asynq
- 112