Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remind101/mq-go
SQS Consumer Server for Go
https://github.com/remind101/mq-go
go golang sqs sqs-consumer
Last synced: 2 months ago
JSON representation
SQS Consumer Server for Go
- Host: GitHub
- URL: https://github.com/remind101/mq-go
- Owner: remind101
- License: bsd-2-clause
- Created: 2018-04-16T21:58:26.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-10T20:37:35.000Z (over 6 years ago)
- Last Synced: 2024-06-19T05:37:17.104Z (7 months ago)
- Topics: go, golang, sqs, sqs-consumer
- Language: Go
- Homepage:
- Size: 355 KB
- Stars: 28
- Watchers: 44
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MQ - A package for consuming SQS message queues
The goal of this project is to provide tooling to utilize SQS effectively in Go.
## Features
* Familiar `net/http` Handler interface.
* Retry with expontial backoff via visibility timeouts and dead letter queues.
* Router Handler for multiplexing messages over a single queue.
* Server with configurable concurrency and graceful shutdown.
* Automatic batch fetching and deletion.
* Publisher for batch sending.
* Opentracing support## Documentation
https://godoc.org/github.com/remind101/mq-go
## QuickStart
``` golang
func main() {
queueURL := "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"h := mq.HandlerFunc(func(m *mq.Message) error {
fmt.Printf("Received message: %s", aws.StringValue(m.SQSMessage.Body))// Returning no error signifies the message was processed successfully.
// The Server will queue the message for deletion.
return nil
})// Configure mq.Server
s := mq.NewServer(queueURL, h)// Start a loop to receive SQS messages and pass them to the Handler.
s.Start()
defer s.Shutdown(context.Background())// Start a publisher
p := mq.NewPublisher(queueURL)
p.Start()
defer p.Shutdown(context.Background())// Publish messages (will be batched).
p.Publish(&sqs.SendMessageBatchRequestEntry{
MessageBody: aws.String("Hello"),
})
p.Publish(&sqs.SendMessageBatchRequestEntry{
MessageBody: aws.String("World!"),
})
}
```