From efeb5e078968dd91e24b9f9922ffa3c77b3de313 Mon Sep 17 00:00:00 2001 From: Robert van Gent Date: Mon, 23 May 2022 14:19:34 -0700 Subject: [PATCH] pubsub/rabbitpubsub: Switch to using github.com/rabbitmq/amqp091-go. --- internal/testing/alldeps | 2 +- internal/website/content/howto/pubsub/publish.md | 2 +- internal/website/content/howto/pubsub/subscribe.md | 2 +- internal/website/data/examples.json | 4 ++-- pubsub/rabbitpubsub/amqp.go | 8 +++++--- pubsub/rabbitpubsub/example_test.go | 2 +- pubsub/rabbitpubsub/fake_test.go | 2 +- pubsub/rabbitpubsub/go.mod | 2 +- pubsub/rabbitpubsub/go.sum | 4 ++-- pubsub/rabbitpubsub/rabbit.go | 6 +++--- pubsub/rabbitpubsub/rabbit_test.go | 2 +- samples/go.sum | 2 ++ 12 files changed, 21 insertions(+), 17 deletions(-) diff --git a/internal/testing/alldeps b/internal/testing/alldeps index 0da5a5b2b9..c44a3ba166 100644 --- a/internal/testing/alldeps +++ b/internal/testing/alldeps @@ -119,9 +119,9 @@ github.com/nats-io/nuid github.com/oklog/run github.com/pierrec/lz4 github.com/pkg/errors +github.com/rabbitmq/amqp091-go github.com/rcrowley/go-metrics github.com/ryanuber/go-glob -github.com/streadway/amqp github.com/xdg-go/pbkdf2 github.com/xdg-go/scram github.com/xdg-go/stringprep diff --git a/internal/website/content/howto/pubsub/publish.md b/internal/website/content/howto/pubsub/publish.md index 310f0f5b87..41eaeef90a 100644 --- a/internal/website/content/howto/pubsub/publish.md +++ b/internal/website/content/howto/pubsub/publish.md @@ -234,7 +234,7 @@ must first create an [`*amqp.Connection`][] to your RabbitMQ instance. {{< goexample "gocloud.dev/pubsub/rabbitpubsub.ExampleOpenTopic" >}} -[`*amqp.Connection`]: https://godoc.org/github.com/streadway/amqp#Connection +[`*amqp.Connection`]: https://pkg.go.dev/github.com/rabbitmq/amqp091-go#Connection [`rabbitpubsub.OpenTopic`]: https://godoc.org/gocloud.dev/pubsub/rabbitpubsub#OpenTopic ### NATS {#nats} diff --git a/internal/website/content/howto/pubsub/subscribe.md b/internal/website/content/howto/pubsub/subscribe.md index 9c08640f3e..a868021f7a 100644 --- a/internal/website/content/howto/pubsub/subscribe.md +++ b/internal/website/content/howto/pubsub/subscribe.md @@ -216,7 +216,7 @@ You must first create an [`*amqp.Connection`][] to your RabbitMQ instance. {{< goexample "gocloud.dev/pubsub/rabbitpubsub.ExampleOpenSubscription" >}} -[`*amqp.Connection`]: https://godoc.org/github.com/streadway/amqp#Connection +[`*amqp.Connection`]: https://pkg.go.dev/github.com/rabbitmq/amqp091-go#Connection [`rabbitpubsub.OpenSubscription`]: https://godoc.org/gocloud.dev/pubsub/rabbitpubsub#OpenSubscription ### NATS {#nats} diff --git a/internal/website/data/examples.json b/internal/website/data/examples.json index 4fc8b50126..8220d75a6a 100644 --- a/internal/website/data/examples.json +++ b/internal/website/data/examples.json @@ -288,11 +288,11 @@ "code": "// pubsub.OpenTopic creates a *pubsub.Topic from a URL.\n// This URL will Dial the NATS server at the URL in the environment variable\n// NATS_SERVER_URL and send messages with subject \"example.mysubject\".\ntopic, err := pubsub.OpenTopic(ctx, \"nats://example.mysubject\")\nif err != nil {\n\treturn err\n}\ndefer topic.Shutdown(ctx)" }, "gocloud.dev/pubsub/rabbitpubsub.ExampleOpenSubscription": { - "imports": "import (\n\t\"context\"\n\n\t\"github.com/streadway/amqp\"\n\t\"gocloud.dev/pubsub/rabbitpubsub\"\n)", + "imports": "import (\n\t\"context\"\n\n\tamqp \"github.com/rabbitmq/amqp091-go\"\n\t\"gocloud.dev/pubsub/rabbitpubsub\"\n)", "code": "rabbitConn, err := amqp.Dial(\"amqp://guest:guest@localhost:5672/\")\nif err != nil {\n\treturn err\n}\ndefer rabbitConn.Close()\nsubscription := rabbitpubsub.OpenSubscription(rabbitConn, \"myqueue\", nil)\ndefer subscription.Shutdown(ctx)" }, "gocloud.dev/pubsub/rabbitpubsub.ExampleOpenTopic": { - "imports": "import (\n\t\"context\"\n\n\t\"github.com/streadway/amqp\"\n\t\"gocloud.dev/pubsub/rabbitpubsub\"\n)", + "imports": "import (\n\t\"context\"\n\n\tamqp \"github.com/rabbitmq/amqp091-go\"\n\t\"gocloud.dev/pubsub/rabbitpubsub\"\n)", "code": "rabbitConn, err := amqp.Dial(\"amqp://guest:guest@localhost:5672/\")\nif err != nil {\n\treturn err\n}\ndefer rabbitConn.Close()\ntopic := rabbitpubsub.OpenTopic(rabbitConn, \"myexchange\", nil)\ndefer topic.Shutdown(ctx)" }, "gocloud.dev/pubsub/rabbitpubsub.Example_openSubscriptionFromURL": { diff --git a/pubsub/rabbitpubsub/amqp.go b/pubsub/rabbitpubsub/amqp.go index d22af156e9..d28831ce6b 100644 --- a/pubsub/rabbitpubsub/amqp.go +++ b/pubsub/rabbitpubsub/amqp.go @@ -17,7 +17,9 @@ package rabbitpubsub // Interfaces for the AMQP protocol, and adapters for the real amqp client. // Fake implementations of the interfaces are in fake_test.go -import "github.com/streadway/amqp" +import ( + amqp "github.com/rabbitmq/amqp091-go" +) // Values we use for the amqp client. // See https://www.rabbitmq.com/amqp-0-9-1-reference.html. @@ -39,13 +41,13 @@ const ( immediate = false ) -// See https://godoc.org/github.com/streadway/amqp#Connection for the documentation of these methods. +// See https://pkg.go.dev/github.com/rabbitmq/amqp091-go#Connection for the documentation of these methods. type amqpConnection interface { Channel() (amqpChannel, error) Close() error } -// See https://godoc.org/github.com/streadway/amqp#Channel for the documentation of these methods. +// See https://pkg.go.dev/github.com/rabbitmq/amqp091-go#Channel for the documentation of these methods. type amqpChannel interface { Publish(exchange string, msg amqp.Publishing) error Consume(queue, consumer string) (<-chan amqp.Delivery, error) diff --git a/pubsub/rabbitpubsub/example_test.go b/pubsub/rabbitpubsub/example_test.go index 413116c19a..fb0c00bf8a 100644 --- a/pubsub/rabbitpubsub/example_test.go +++ b/pubsub/rabbitpubsub/example_test.go @@ -18,7 +18,7 @@ import ( "context" "log" - "github.com/streadway/amqp" + amqp "github.com/rabbitmq/amqp091-go" "gocloud.dev/pubsub" "gocloud.dev/pubsub/rabbitpubsub" ) diff --git a/pubsub/rabbitpubsub/fake_test.go b/pubsub/rabbitpubsub/fake_test.go index 192a93bcc7..9cd11f3b32 100644 --- a/pubsub/rabbitpubsub/fake_test.go +++ b/pubsub/rabbitpubsub/fake_test.go @@ -23,7 +23,7 @@ import ( "sync" "time" - "github.com/streadway/amqp" + amqp "github.com/rabbitmq/amqp091-go" ) // fakeConnection implements the amqpConnection interface. diff --git a/pubsub/rabbitpubsub/go.mod b/pubsub/rabbitpubsub/go.mod index 7e3502ef6c..f90bc1ddfc 100644 --- a/pubsub/rabbitpubsub/go.mod +++ b/pubsub/rabbitpubsub/go.mod @@ -17,7 +17,7 @@ module gocloud.dev/pubsub/rabbitpubsub go 1.12 require ( - github.com/streadway/amqp v1.0.0 + github.com/rabbitmq/amqp091-go v1.3.4 gocloud.dev v0.25.0 ) diff --git a/pubsub/rabbitpubsub/go.sum b/pubsub/rabbitpubsub/go.sum index 74c21dd93f..bc76ac5a43 100644 --- a/pubsub/rabbitpubsub/go.sum +++ b/pubsub/rabbitpubsub/go.sum @@ -408,6 +408,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rabbitmq/amqp091-go v1.3.4 h1:tXuIslN1nhDqs2t6Jrz3BAoqvt4qIZzxvdbdcxWtHYU= +github.com/rabbitmq/amqp091-go v1.3.4/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -419,8 +421,6 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/streadway/amqp v1.0.0 h1:kuuDrUJFZL1QYL9hUNuCxNObNzB0bV/ZG5jV3RWAQgo= -github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= 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= diff --git a/pubsub/rabbitpubsub/rabbit.go b/pubsub/rabbitpubsub/rabbit.go index cc45399d15..7bfed94554 100644 --- a/pubsub/rabbitpubsub/rabbit.go +++ b/pubsub/rabbitpubsub/rabbit.go @@ -26,7 +26,7 @@ import ( "sync/atomic" "time" - "github.com/streadway/amqp" + amqp "github.com/rabbitmq/amqp091-go" "gocloud.dev/gcerrors" "gocloud.dev/pubsub" "gocloud.dev/pubsub/driver" @@ -440,8 +440,8 @@ func isRetryable(err error) bool { // But it actually means "can be recovered by retrying later or with different // parameters," which is not what we want. The error codes for which Recover is // true, defined in the isSoftExceptionCode function of - // github.com/streadway/amqp/spec091.go, include things like NotFound and - // AccessRefused, which require outside action. + // https://github.com/rabbitmq/amqp091-go/blob/main/spec091.go, includng things + // like NotFound and AccessRefused, which require outside action. // // The following are the codes which might be resolved by retry without external // action, according to the AMQP 0.91 spec diff --git a/pubsub/rabbitpubsub/rabbit_test.go b/pubsub/rabbitpubsub/rabbit_test.go index f59d9895e3..8f246a843b 100644 --- a/pubsub/rabbitpubsub/rabbit_test.go +++ b/pubsub/rabbitpubsub/rabbit_test.go @@ -30,7 +30,7 @@ import ( "testing" "time" - "github.com/streadway/amqp" + amqp "github.com/rabbitmq/amqp091-go" "gocloud.dev/gcerrors" "gocloud.dev/internal/testing/setup" "gocloud.dev/pubsub" diff --git a/samples/go.sum b/samples/go.sum index d908c1dee8..f8aa56dbb3 100644 --- a/samples/go.sum +++ b/samples/go.sum @@ -670,6 +670,8 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/rabbitmq/amqp091-go v1.3.4 h1:tXuIslN1nhDqs2t6Jrz3BAoqvt4qIZzxvdbdcxWtHYU= +github.com/rabbitmq/amqp091-go v1.3.4/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=