-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
38 lines (30 loc) · 883 Bytes
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package sqsworker_test
import (
"context"
"github.com/ajbeach2/sqsworker"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sns"
"github.com/aws/aws-sdk-go/service/sqs"
"strings"
)
type LowerCaseWorker struct {
}
func (l *LowerCaseWorker) Process(ctx context.Context, m *sqs.Message, w *sns.PublishInput) error {
*w.Message = strings.ToLower(*m.Body)
return nil
}
func ExampleWorker() {
lowerCaseWorker := &LowerCaseWorker{}
sess := session.New(&aws.Config{Region: aws.String("us-east-1")})
queueURL, _ := sqsworker.GetOrCreateQueue("In", sqs.New(sess))
topicArn, _ := sqsworker.GetOrCreateTopic("Out", sns.New(sess))
w := sqsworker.NewWorker(sess, sqsworker.WorkerConfig{
QueueURL: queueURL,
TopicArn: topicArn,
Workers: 1,
Processor: lowerCaseWorker,
Name: "TestApp",
})
w.Run()
}