Skip to content

Commit 15ce62f

Browse files
committed
chore: move to a maintained repo of amqp
1 parent 8b29494 commit 15ce62f

3 files changed

Lines changed: 33 additions & 23 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ require (
1212
github.com/knadh/koanf/providers/file v1.1.2
1313
github.com/knadh/koanf/v2 v2.1.2
1414
github.com/lib/pq v1.10.9
15+
github.com/rabbitmq/amqp091-go v1.10.0
1516
github.com/rs/zerolog v1.33.0
1617
github.com/spf13/pflag v1.0.5
17-
github.com/streadway/amqp v1.1.0
1818
github.com/stretchr/testify v1.9.0
1919
github.com/valyala/fasthttp v1.57.0
2020
)

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5h
7070
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
7171
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7272
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
73+
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
74+
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
7375
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
7476
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
7577
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
@@ -79,8 +81,6 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
7981
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
8082
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
8183
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
82-
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
83-
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
8484
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
8585
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
8686
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
@@ -93,6 +93,8 @@ github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVS
9393
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
9494
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
9595
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
96+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
97+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
9698
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
9799
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
98100
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

storage/rabbitmq/rabbitmq.go

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@ import (
77
"time"
88

99
"github.com/42atomys/webhooked/internal/valuable"
10+
amqp "github.com/rabbitmq/amqp091-go"
1011
"github.com/rs/zerolog/log"
11-
"github.com/streadway/amqp"
1212
)
1313

1414
type RabbitmqStorageSpec struct {
15-
DatabaseURL valuable.Valuable `mapstructure:"databaseUrl" json:"databaseUrl"`
16-
QueueName string `mapstructure:"queueName" json:"queueName"`
17-
DefinedContentType string `mapstructure:"contentType" json:"contentType"`
18-
Durable bool `mapstructure:"durable" json:"durable"`
19-
DeleteWhenUnused bool `mapstructure:"deleteWhenUnused" json:"deleteWhenUnused"`
20-
Exclusive bool `mapstructure:"exclusive" json:"exclusive"`
21-
NoWait bool `mapstructure:"noWait" json:"noWait"`
22-
Mandatory bool `mapstructure:"mandatory" json:"mandatory"`
23-
Immediate bool `mapstructure:"immediate" json:"immediate"`
24-
Exchange string `mapstructure:"exchange" json:"exchange"`
25-
MaxAttempt int `mapstructure:"maxAttempt" json:"maxAttempt"`
26-
27-
client *amqp.Connection
28-
channel *amqp.Channel
29-
routingKey amqp.Queue
15+
DatabaseURL valuable.Valuable `mapstructure:"databaseUrl" json:"databaseUrl"`
16+
MaxAttempt int `mapstructure:"maxAttempt" json:"maxAttempt"`
17+
// QueueDeclare
18+
QueueName string `mapstructure:"queueName" json:"queueName"`
19+
Durable *bool `mapstructure:"durable" json:"durable"`
20+
DeleteWhenUnused bool `mapstructure:"deleteWhenUnused" json:"deleteWhenUnused"`
21+
Exclusive bool `mapstructure:"exclusive" json:"exclusive"`
22+
NoWait bool `mapstructure:"noWait" json:"noWait"`
23+
// Publish
24+
Exchange string `mapstructure:"exchange" json:"exchange"`
25+
DefinedContentType string `mapstructure:"contentType" json:"contentType"`
26+
Mandatory bool `mapstructure:"mandatory" json:"mandatory"`
27+
Immediate bool `mapstructure:"immediate" json:"immediate"`
28+
29+
client *amqp.Connection
30+
channel *amqp.Channel
31+
queue amqp.Queue
3032
}
3133

3234
func (s *RabbitmqStorageSpec) EnsureConfigurationCompleteness() error {
@@ -38,6 +40,11 @@ func (s *RabbitmqStorageSpec) EnsureConfigurationCompleteness() error {
3840
s.MaxAttempt = 5
3941
}
4042

43+
if s.Durable == nil {
44+
durable := true
45+
s.Durable = &durable
46+
}
47+
4148
return nil
4249
}
4350

@@ -61,9 +68,9 @@ func (s *RabbitmqStorageSpec) Initialize() error {
6168
}
6269
}()
6370

64-
if s.routingKey, err = s.channel.QueueDeclare(
71+
if s.queue, err = s.channel.QueueDeclare(
6572
s.QueueName,
66-
s.Durable,
73+
*s.Durable,
6774
s.DeleteWhenUnused,
6875
s.Exclusive,
6976
s.NoWait,
@@ -77,9 +84,10 @@ func (s *RabbitmqStorageSpec) Initialize() error {
7784

7885
func (s *RabbitmqStorageSpec) Store(ctx context.Context, value []byte) error {
7986
for attempt := 0; attempt < s.MaxAttempt; attempt++ {
80-
err := s.channel.Publish(
87+
err := s.channel.PublishWithContext(
88+
ctx,
8189
s.Exchange,
82-
s.routingKey.Name,
90+
s.queue.Name,
8391
s.Mandatory,
8492
s.Immediate,
8593
amqp.Publishing{

0 commit comments

Comments
 (0)