Skip to content

Commit

Permalink
amqp: migrate to maintained package
Browse files Browse the repository at this point in the history
Closes: #1793
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Nov 14, 2023
1 parent a359eb0 commit 8fcd294
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ require (
github.com/quay/clair/config v1.3.0
github.com/quay/claircore v1.5.20
github.com/quay/zlog v1.1.5
github.com/rabbitmq/amqp091-go v1.9.0
github.com/remind101/migrate v0.0.0-20170729031349-52c1edff7319
github.com/rs/zerolog v1.31.0
github.com/streadway/amqp v1.1.0
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
github.com/ugorji/go/codec v1.2.11
github.com/urfave/cli/v2 v2.25.7
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ github.com/quay/goval-parser v0.8.8 h1:Uf+f9iF2GIR5GPUY2pGoa9il2+4cdES44ZlM0mWm4
github.com/quay/goval-parser v0.8.8/go.mod h1:Y0NTNfPYOC7yxsYKzJOrscTWUPq1+QbtHw4XpPXWPMc=
github.com/quay/zlog v1.1.5 h1:A+gF+FjN0A/qkl4E991ot2YJwjmNmsTlwUs/yRoEI7g=
github.com/quay/zlog v1.1.5/go.mod h1:wg9IIQicn8f4ofUbCTC51FmqpxTpsGOQU+hIeIAe8Aw=
github.com/rabbitmq/amqp091-go v1.9.0 h1:qrQtyzB4H8BQgEuJwhmVQqVHB9O4+MNDJCCAcpc3Aoo=
github.com/rabbitmq/amqp091-go v1.9.0/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
github.com/remind101/migrate v0.0.0-20170729031349-52c1edff7319 h1:ukjThsA2ou7AmovpwtMVkNQSuoN/v5U16+JomTz3c7o=
github.com/remind101/migrate v0.0.0-20170729031349-52c1edff7319/go.mod h1:rhSvwcijY9wfmrBYrfCvapX8/xOTV46NAUjBRgUyJqc=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
Expand All @@ -223,8 +225,6 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.1 h1:Ou41VVR3nMWWmTiEUnj0OlsgOSCUFgsPAOl6jRIcVtQ=
github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
Expand Down Expand Up @@ -276,6 +276,8 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
Expand Down
4 changes: 2 additions & 2 deletions notifier/amqp/deliverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/google/uuid"
"github.com/quay/clair/config"
samqp "github.com/streadway/amqp"
amqp "github.com/rabbitmq/amqp091-go"

clairerror "github.com/quay/clair/v4/clair-error"
"github.com/quay/clair/v4/notifier"
Expand Down Expand Up @@ -97,7 +97,7 @@ func (d *Deliverer) Deliver(ctx context.Context, nID uuid.UUID) error {
if err != nil {
return &clairerror.ErrDeliveryFailed{err}
}
msg := samqp.Publishing{
msg := amqp.Publishing{
ContentType: "application/json",
AppId: "clairV4-notifier",
Body: b,
Expand Down
6 changes: 3 additions & 3 deletions notifier/amqp/deliverer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/quay/clair/config"
"github.com/quay/claircore/test/integration"
"github.com/quay/zlog"
samqp "github.com/streadway/amqp"
amqp "github.com/rabbitmq/amqp091-go"
)

const (
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestDeliverer(t *testing.T) {
uri,
}

conn, err := samqp.Dial(uri)
conn, err := amqp.Dial(uri)
if err != nil {
t.Fatalf("failed to connect to broker at %v: %v", uri, err)
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestDeliverer(t *testing.T) {
}

// create consumer
consumerConn, err := samqp.Dial(uri)
consumerConn, err := amqp.Dial(uri)
if err != nil {
t.Fatalf("failed to create consumer connection: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions notifier/amqp/directdeliverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/google/uuid"
"github.com/quay/clair/config"
samqp "github.com/streadway/amqp"
amqp "github.com/rabbitmq/amqp091-go"

clairerror "github.com/quay/clair/v4/clair-error"
"github.com/quay/clair/v4/notifier"
Expand Down Expand Up @@ -95,7 +95,7 @@ func (d *DirectDeliverer) Deliver(ctx context.Context, _ uuid.UUID) error {
ch.TxRollback()
return &clairerror.ErrDeliveryFailed{err}
}
msg := samqp.Publishing{
msg := amqp.Publishing{
ContentType: "application/json",
AppId: "clairV4-notifier",
Body: buf.Bytes(),
Expand Down
6 changes: 3 additions & 3 deletions notifier/amqp/directdeliverer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/quay/claircore"
"github.com/quay/claircore/test/integration"
"github.com/quay/zlog"
samqp "github.com/streadway/amqp"
amqp "github.com/rabbitmq/amqp091-go"
"golang.org/x/sync/errgroup"

"github.com/quay/clair/v4/notifier"
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestDirectDeliverer(t *testing.T) {
uri = defaultRabbitMQURI
}
t.Logf("using uri: %q", uri)
conn, err := samqp.Dial(uri)
conn, err := amqp.Dial(uri)
if err != nil {
t.Fatalf("failed to connect to broker at %v: %v", uri, err)
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestDirectDeliverer(t *testing.T) {
}

// create consumer
consumerConn, err := samqp.Dial(uri)
consumerConn, err := amqp.Dial(uri)
if err != nil {
t.Fatalf("failed to create consumer connection: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions notifier/amqp/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/quay/clair/config"
"github.com/quay/zlog"
samqp "github.com/streadway/amqp"
amqp "github.com/rabbitmq/amqp091-go"
)

// failOver will return the first successful connection made against the provided
Expand All @@ -18,15 +18,15 @@ import (
// failOver is safe for concurrent usage.
type failOver struct {
sync.RWMutex
conn *samqp.Connection
conn *amqp.Connection
tls *tls.Config
exchange *config.Exchange
uris []*url.URL
}

// Connection returns an AMQP connection to the first broker which successfully
// handshakes.
func (f *failOver) Connection(ctx context.Context) (*samqp.Connection, error) {
func (f *failOver) Connection(ctx context.Context) (*amqp.Connection, error) {
ctx = zlog.ContextWithValues(ctx,
"component", "notifier/amqp/failOver.Connection")

Expand All @@ -43,7 +43,7 @@ func (f *failOver) Connection(ctx context.Context) (*samqp.Connection, error) {
ctx := zlog.ContextWithValues(ctx, "broker", uri.String())
// safe to always call DialTLS per docs:
// 'DialTLS will use the provided tls.Config when it encounters an amqps:// scheme and will dial a plain connection when it encounters an amqp:// scheme.'
conn, err := samqp.DialTLS(uri.String(), f.tls)
conn, err := amqp.DialTLS(uri.String(), f.tls)
if err != nil {
if conn != nil {
conn.Close()
Expand Down

0 comments on commit 8fcd294

Please sign in to comment.