Documentation ¶
Index ¶
- Constants
- Variables
- func CreateSqsQueue(sqsClient *sqs.SQS, queue string) (*string, error)
- func CreateSqsQueueIfNotExist(sqsClient *sqs.SQS, queue string) (*string, error)
- func DeleteSqsQueue(sqsClient *sqs.SQS, queue string) error
- func MapToJSON(m map[string]interface{}) string
- type Dequeuer
- type Enqueuer
- type Job
- type JobHandler
- type Worker
- type WorkerPool
Constants ¶
View Source
const (
JobNameAttr = "job_name"
)
View Source
const (
MaxNumberOfMessages = 10
)
Variables ¶
View Source
var DefaultWaitTime int64 = 10
DefaultWaitTime default seconds for wating to receive jobs from the queue
Functions ¶
func CreateSqsQueue ¶
CreateSqsQueue create SQS queue
func CreateSqsQueueIfNotExist ¶
CreateSqsQueueIfNotExist create sqs if not exist
func DeleteSqsQueue ¶
DeleteSqsQueue deletes a sqs queue
Types ¶
type Dequeuer ¶
type Dequeuer struct {
// contains filtered or unexported fields
}
Dequeuer present a dequeuer
func NewDequeuer ¶
func NewDequeuer(queueURL *string, sqsClient *sqs.SQS, visibleTimeout int64, maxJobs int64) *Dequeuer
NewDequeuer create a new dequeuer
type Enqueuer ¶
type Enqueuer struct {
// contains filtered or unexported fields
}
Enqueuer presents an queuer
func NewEnqueuer ¶
NewEnqueuer creates new Enqueuer
type Job ¶
type Job struct { ID *string Name string ReceiptID *string Args map[string]interface{} Retries int }
Job represents a job.
func SqsMessageToJob ¶
SqsMessageToJob converts sqs message to a job
func (*Job) SqsMessage ¶
func (job *Job) SqsMessage() (*sqs.SendMessageInput, error)
SqsMessage convert Job to SendMessageInput
type JobHandler ¶
JobHandler signature function to consume a job
type Worker ¶
type Worker struct {
Pool *WorkerPool
}
func NewWorker ¶
func NewWorker(pool *WorkerPool) *Worker
type WorkerPool ¶
WorkerPool represents a pool of workers
func New ¶
func New(queue string, maxWorkers int64, sqsClient *sqs.SQS) *WorkerPool
New create a new WorkerPool
func (*WorkerPool) Enqueue ¶
func (pool *WorkerPool) Enqueue(name string, args map[string]interface{}) (*Job, error)
Enqueue enqueues a new job
func (*WorkerPool) ExistJobHandler ¶
func (pool *WorkerPool) ExistJobHandler(name string) bool
ExistJobHandler check whether a job handler has been registered
func (*WorkerPool) RegisterJobHandler ¶
func (pool *WorkerPool) RegisterJobHandler(name string, handler JobHandler)
RegisterJobHandler register job handlers before start workers
Source Files ¶
Click to show internal directories.
Click to hide internal directories.