# README
asyncq
Async Job processor
Quick start
- Install package using
go get -u github.com/anandpathak/asynq
- Below is the example of creating client for async processing
import (
"github.com/anandpathak/asyncq"
)
func main(){
consumer := eventConsumer{}
// this will create a queue
queue := asyncq.New(retryCount, bufferSize, poolSize , delay, consumer)
// start the queue
queue.Start()
}
type eventConsumer struct {}
func (p eventConsumer)Process(j *asyncq.Job ) error {
// add your consumer logic in Process
return nil
}
- You can create jobs and pass to the async queue. async queue will pull message, and process
// create the job to process
job := asyncq.Job{
Params:[]string{"hello", "world"},
ID: "testJob1",
}
// Add job to queue
queue.Add(&job)
- You can close the consumer to stop receiving the message
queue.Close()
# Constants
FailureJobState represent that the job is failed to process.
ProcessingJobState represents that the Job is still in process in the queue.
SuccessJobState represent that the job is successfully processed from the queue.
# Interfaces
Processor is interface type to allow client to define Process method Queue will trigger process on a Job that is pushed to the queue.
# Type aliases
JobState represent the Job state in queue.