Skip to content

Commit

Permalink
Restore the Azure Client (#11)
Browse files Browse the repository at this point in the history
The null value is fixed here Azure/go-amqp#336

Signed-off-by: Gabriele Santomaggio <[email protected]>
  • Loading branch information
Gsantomaggio authored Sep 16, 2024
1 parent 05f7cd9 commit 189408c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
1 change: 0 additions & 1 deletion examples/getting_started/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

func main() {
fmt.Printf("Getting started with AMQP Go AMQP 1.0 Client\n")

chStatusChanged := make(chan *mq.StatusChanged, 1)

go func(ch chan *mq.StatusChanged) {
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/rabbitmq/rabbitmq-amqp-go-client
go 1.22.0

require (
github.com/Azure/go-amqp v0.0.0-00010101000000-000000000000
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
)

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-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand All @@ -20,5 +20,3 @@ require (
golang.org/x/tools v0.24.0 // 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 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
7 changes: 5 additions & 2 deletions rabbitmq_amqp/amqp_binding.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package rabbitmq_amqp

import "context"
import (
"context"
"github.com/Azure/go-amqp"
)

type AMQPBindingInfo struct {
}
Expand Down Expand Up @@ -46,6 +49,6 @@ func (b *AMQPBinding) Bind(ctx context.Context) error {

func (b *AMQPBinding) Unbind(ctx context.Context) error {
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
}
7 changes: 5 additions & 2 deletions rabbitmq_amqp/amqp_exchange.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package rabbitmq_amqp

import "context"
import (
"context"
"github.com/Azure/go-amqp"
)

type AmqpExchangeInfo struct {
name string
Expand Down Expand Up @@ -56,7 +59,7 @@ func (e *AmqpExchange) IsAutoDelete() bool {

func (e *AmqpExchange) Delete(ctx context.Context) error {
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
}

Expand Down
6 changes: 4 additions & 2 deletions rabbitmq_amqp/amqp_managent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
expectedResponseCodes []int) (map[string]any, error) {
amqpMessage := amqp.NewMessageWithValue(body)
amqpMessage := &amqp.Message{
Value: body,
}
s := commandReplyTo
amqpMessage.Properties = &amqp.MessageProperties{
ReplyTo: &s,
Expand Down
3 changes: 2 additions & 1 deletion rabbitmq_amqp/amqp_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rabbitmq_amqp

import (
"context"
"github.com/Azure/go-amqp"
)

type AmqpQueueInfo struct {
Expand Down Expand Up @@ -161,7 +162,7 @@ func (a *AmqpQueue) Declare(ctx context.Context) (IQueueInfo, error) {

func (a *AmqpQueue) Delete(ctx context.Context) error {
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
}

Expand Down

0 comments on commit 189408c

Please sign in to comment.