Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // 每次获取最大的消息数量。默认 10 个 MaxNumberOfMessage int64 // SQS Queue URL 地址 QueueURL string // 等待时间,单位秒。默认 20s // The duration (in seconds) for which the call waits for a message to arrive in the queue before returning. // If a message is available, the call returns sooner than WaitTimeSeconds. // If no messages are available and the wait time expires, the call returns successfully with an empty list of messages. // https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html WaitTimeSecond int64 // 消息可见超时时间,单位秒。默认 20s // The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. // https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html VisibilityTimeout int64 // Worker 大小,默认 1 WorkerSize int64 // Logger Logger Logger }
Config 配置
type HandlerFunc ¶
HandlerFunc is used to define the Handler that is run on for each message
func (HandlerFunc) HandleMessage ¶
func (f HandlerFunc) HandleMessage(msg *sqs.Message) error
HandleMessage wraps a function for handling sqs messages
type Logger ¶
type Logger interface { Debug(args ...interface{}) Info(args ...interface{}) Error(args ...interface{}) }
Logger interface
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
A Worker is a individual processor of jobs from the job channel.
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
A WorkerPool provides a collection of workers, and access to their lifecycle.
func NewWorkerPool ¶
NewWorkerPool creates a new instance of the worker pool, and creates all the workers in the pool. The workers are spun off in their own goroutines and the WorkerPool's wait group is used to know when the workers all completed their work and existed.
func (*WorkerPool) Run ¶
func (w *WorkerPool) Run(handler Handler)
func (*WorkerPool) WaitForWorkersDone ¶
func (w *WorkerPool) WaitForWorkersDone()
WaitForWorkersDone waits for the works to of all completed their work and exited.