Skip to content

Commit

Permalink
renamed config
Browse files Browse the repository at this point in the history
  • Loading branch information
engelmi committed Sep 7, 2021
1 parent fbfa911 commit 9dbed02
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import (
"github.com/sirupsen/logrus"
)

type Config struct {
type QueueConfig struct {
Region string
Endpoint string
Queue string
}

type ProducerConfig struct {
Config
QueueConfig
Timeout time.Duration
}

type ConsumerConfig struct {
Config
QueueConfig
PollTimeout time.Duration
AckTimeout time.Duration
MaxNumberOfMessages int64
Expand Down
4 changes: 2 additions & 2 deletions examples/gopher.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (g Gopher) PushMessage(msg string) {

func (g Gopher) setupProducer() gosqs.Producer {
p, err := gosqs.NewProducer(gosqs.ProducerConfig{
Config: gosqs.Config{
QueueConfig: gosqs.QueueConfig{
Region: "eu-central-1",
Endpoint: "http://localhost:9324",
Queue: g.queueName,
Expand All @@ -60,7 +60,7 @@ func (g Gopher) sendMessage(p gosqs.Producer, msg string) {

func (g Gopher) Consume() {
consumer, err := gosqs.NewConsumer(gosqs.ConsumerConfig{
Config: gosqs.Config{
QueueConfig: gosqs.QueueConfig{
Region: "eu-central-1",
Endpoint: "http://localhost:9324",
Queue: g.queueName,
Expand Down
7 changes: 2 additions & 5 deletions examples/panic/panic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ func main() {
wg := &sync.WaitGroup{}

handler := func(ctx context.Context, receivedMsg *sqs.Message) error {
defer wg.Done()

fmt.Println(fmt.Sprintf("Got message '%s'", *receivedMsg.Body))
panic(fmt.Sprintf("Handler panic for message '%s'", *receivedMsg.Body))
}

consumer, err := gosqs.NewConsumer(gosqs.ConsumerConfig{
Config: gosqs.Config{
QueueConfig: gosqs.QueueConfig{
Region: "eu-central-1",
Endpoint: "http://localhost:9324",
Queue: "panic_queue",
Expand All @@ -39,9 +37,8 @@ func main() {
go consumer.StartListening(context.Background(), nil)

examples.NewGopher("panic_queue", "PushingGopher-1", 1*time.Second).PushMessage("Hello World! No. 1")
wg.Add(1)
examples.NewGopher("panic_queue", "PushingGopher-1", 1*time.Second).PushMessage("Hello World! No. 2")
wg.Add(1)

wg.Add(1)
wg.Wait()
}
10 changes: 10 additions & 0 deletions examples/panic/queues.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,15 @@ queues {
delay = 0 seconds
receiveMessageWait = 0 seconds
fifo = false
deadLettersQueue {
name = "panic_deadletter_queue"
maxReceiveCount = 3
}
}
panic_deadletter_queue {
defaultVisibilityTimeout = 1 seconds
delay = 0 seconds
receiveMessageWait = 0 seconds
fifo = false
}
}
2 changes: 1 addition & 1 deletion examples/simpleConsume/simpleConsume.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
}

consumer, err := gosqs.NewConsumer(gosqs.ConsumerConfig{
Config: gosqs.Config{
QueueConfig: gosqs.QueueConfig{
Region: "eu-central-1",
Endpoint: "http://localhost:9324",
Queue: "simple_consume",
Expand Down
2 changes: 1 addition & 1 deletion examples/simpleProduce/simpleProduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func main() {
p, err := gosqs.NewProducer(gosqs.ProducerConfig{
Config: gosqs.Config{
QueueConfig: gosqs.QueueConfig{
Region: "eu-central-1",
Endpoint: "http://localhost:9324",
Queue: "simple_produce",
Expand Down

0 comments on commit 9dbed02

Please sign in to comment.