Categorygithub.com/anandpathak/asyncq
modulepackage
1.0.1
Repository: https://github.com/anandpathak/asyncq.git
Documentation: pkg.go.dev

# 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()

# Functions

New returns a async queue instance.
No description provided by the author

# 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.

# Structs

Job structure hold the information for each message that needs to be processed from the queue.
Queue is a structure represent async event Processor.

# 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.