-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Additional example and updated the readme
- Loading branch information
Jon Whitcraft
committed
Jan 28, 2017
1 parent
73b613e
commit 2788801
Showing
4 changed files
with
65 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
# sqs-queue | ||
GoLang SQS Queue Worker using the AWS SDK | ||
# go-sqs-poller | ||
|
||
This is based off of [golang-sqs-worker-example](https://github.com/nabeken/golang-sqs-worker-example) but it uses the [official AWS golang SDK](https://github.com/aws/aws-sdk-go). | ||
GoLang SQS Queue Poller using the AWS SDK | ||
|
||
When running this make sure that you specify `AWS_SDK_LOAD_CONFIG=true` before running. It will pick up credentials from the `~/.aws/config` file. | ||
This is based off of [golang-sqs-worker-example](https://github.com/nabeken/golang-sqs-worker-example) but it uses the [official AWS golang SDK](https://github.com/aws/aws-sdk-go). | ||
|
||
### To Do | ||
- Add support for passing in access keys when creating the sqs service instead of auto loading them. | ||
Check out the [cmd/example-worker](cmd/example-worker) directory for examples of how to use the worker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/service/sqs" | ||
"github.com/aws/aws-sdk-go/aws" | ||
|
||
"github.com/jwhitcraft/sqs-queue/worker" | ||
) | ||
|
||
func main() { | ||
// Make sure that AWS_SDK_LOAD_CONFIG=true is defined as an environment variable before running the application | ||
// like this | ||
|
||
// create the new client and return the url | ||
svc, url := worker.NewSQSClient("go-webhook-queue-test") | ||
// set the queue url | ||
worker.QueueURL = url | ||
// start the worker | ||
worker.Start(svc, worker.HandlerFunc(func (msg *sqs.Message) error { | ||
fmt.Println(aws.StringValue(msg.Body)) | ||
return nil | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/service/sqs" | ||
"github.com/aws/aws-sdk-go/aws" | ||
|
||
"github.com/jwhitcraft/sqs-queue/worker" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
) | ||
|
||
var ( | ||
aws_access_key string | ||
aws_secret_key string | ||
aws_region string | ||
) | ||
|
||
func main() { | ||
|
||
// create a config | ||
aws_config := &aws.Config{ | ||
Credentials: credentials.NewStaticCredentials(aws_access_key, aws_secret_key, ""), | ||
Region: aws.String(aws_region), | ||
} | ||
|
||
// create the new client with the aws_config passed in | ||
svc, url := worker.NewSQSClient("go-webhook-queue-test", aws_config) | ||
// set the queue url | ||
worker.QueueURL = url | ||
// start the worker | ||
worker.Start(svc, worker.HandlerFunc(func(msg *sqs.Message) error { | ||
fmt.Println(aws.StringValue(msg.Body)) | ||
return nil | ||
})) | ||
} |
This file was deleted.
Oops, something went wrong.