Restore the Azure Client (#11)

The null value is fixed here https://github.com/Azure/go-amqp/pull/336

Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
This commit is contained in:
Gabriele Santomaggio 2024-09-16 09:34:27 +02:00 committed by GitHub
parent 05f7cd9fbb
commit 189408c5bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 19 additions and 11 deletions

View File

@ -11,7 +11,6 @@ import (
func main() { func main() {
fmt.Printf("Getting started with AMQP Go AMQP 1.0 Client\n") fmt.Printf("Getting started with AMQP Go AMQP 1.0 Client\n")
chStatusChanged := make(chan *mq.StatusChanged, 1) chStatusChanged := make(chan *mq.StatusChanged, 1)
go func(ch chan *mq.StatusChanged) { go func(ch chan *mq.StatusChanged) {

4
go.mod
View File

@ -3,12 +3,12 @@ module github.com/rabbitmq/rabbitmq-amqp-go-client
go 1.22.0 go 1.22.0
require ( require (
github.com/Azure/go-amqp v0.0.0-00010101000000-000000000000
github.com/onsi/ginkgo/v2 v2.20.2 github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2 github.com/onsi/gomega v1.34.2
) )
require ( require (
github.com/Azure/go-amqp v1.1.1-0.20240913224415-f631e6909719 // indirect
github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/logr v1.4.2 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-cmp v0.6.0 // indirect
@ -20,5 +20,3 @@ require (
golang.org/x/tools v0.24.0 // indirect golang.org/x/tools v0.24.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/Azure/go-amqp => github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48

2
go.sum
View File

@ -1,3 +1,5 @@
github.com/Azure/go-amqp v1.1.1-0.20240913224415-f631e6909719 h1:rL7yrEV9yputQV7T+Y9eJVmTVkK4B0aHlBc8TUITC5A=
github.com/Azure/go-amqp v1.1.1-0.20240913224415-f631e6909719/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE=
github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48 h1:etxEtd7qkhJD34gpQesPbZuMJrqkc+ZOXqR3diVfGWs= github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48 h1:etxEtd7qkhJD34gpQesPbZuMJrqkc+ZOXqR3diVfGWs=
github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

View File

@ -1,6 +1,9 @@
package rabbitmq_amqp package rabbitmq_amqp
import "context" import (
"context"
"github.com/Azure/go-amqp"
)
type AMQPBindingInfo struct { type AMQPBindingInfo struct {
} }
@ -46,6 +49,6 @@ func (b *AMQPBinding) Bind(ctx context.Context) error {
func (b *AMQPBinding) Unbind(ctx context.Context) error { func (b *AMQPBinding) Unbind(ctx context.Context) error {
bindingPathWithExchangeQueueKey := bindingPathWithExchangeQueueKey(b.sourceExchangeName, b.destinationQueue, b.bindingKey) bindingPathWithExchangeQueueKey := bindingPathWithExchangeQueueKey(b.sourceExchangeName, b.destinationQueue, b.bindingKey)
_, err := b.management.Request(ctx, nil, bindingPathWithExchangeQueueKey, commandDelete, []int{responseCode204}) _, err := b.management.Request(ctx, amqp.Null{}, bindingPathWithExchangeQueueKey, commandDelete, []int{responseCode204})
return err return err
} }

View File

@ -1,6 +1,9 @@
package rabbitmq_amqp package rabbitmq_amqp
import "context" import (
"context"
"github.com/Azure/go-amqp"
)
type AmqpExchangeInfo struct { type AmqpExchangeInfo struct {
name string name string
@ -56,7 +59,7 @@ func (e *AmqpExchange) IsAutoDelete() bool {
func (e *AmqpExchange) Delete(ctx context.Context) error { func (e *AmqpExchange) Delete(ctx context.Context) error {
path := exchangePath(e.name) path := exchangePath(e.name)
_, err := e.management.Request(ctx, nil, path, commandDelete, []int{responseCode204}) _, err := e.management.Request(ctx, amqp.Null{}, path, commandDelete, []int{responseCode204})
return err return err
} }

View File

@ -154,12 +154,14 @@ func (a *AmqpManagement) validateResponseCode(responseCode int, expectedResponse
} }
} }
return PreconditionFailed return errors.New(fmt.Sprintf("expected response code %d got %d", expectedResponseCodes, responseCode))
} }
func (a *AmqpManagement) request(ctx context.Context, id string, body any, path string, method string, func (a *AmqpManagement) request(ctx context.Context, id string, body any, path string, method string,
expectedResponseCodes []int) (map[string]any, error) { expectedResponseCodes []int) (map[string]any, error) {
amqpMessage := amqp.NewMessageWithValue(body) amqpMessage := &amqp.Message{
Value: body,
}
s := commandReplyTo s := commandReplyTo
amqpMessage.Properties = &amqp.MessageProperties{ amqpMessage.Properties = &amqp.MessageProperties{
ReplyTo: &s, ReplyTo: &s,

View File

@ -2,6 +2,7 @@ package rabbitmq_amqp
import ( import (
"context" "context"
"github.com/Azure/go-amqp"
) )
type AmqpQueueInfo struct { type AmqpQueueInfo struct {
@ -161,7 +162,7 @@ func (a *AmqpQueue) Declare(ctx context.Context) (IQueueInfo, error) {
func (a *AmqpQueue) Delete(ctx context.Context) error { func (a *AmqpQueue) Delete(ctx context.Context) error {
path := queuePath(a.name) path := queuePath(a.name)
_, err := a.management.Request(ctx, nil, path, commandDelete, []int{responseCode200}) _, err := a.management.Request(ctx, amqp.Null{}, path, commandDelete, []int{responseCode200})
return err return err
} }