Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1039 Migrate azure/go-amqp to version 1.0.5 #1040

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cx-joses
Copy link

@cx-joses cx-joses commented Apr 24, 2024

Changes:

Fixes #1039

  • migrate dependent packages to the latest version
  • migrate azure/go-amqp from 0.17 to 1.0.5

@embano1
Copy link
Member

embano1 commented Apr 24, 2024

Thx for the quick fix! Question: is the reason to bump to go 1.22 due to the amqp bump or actually not needed?

type receiver struct{ amqp *amqp.Receiver }
type receiver struct {
amqp *amqp.Receiver
options *amqp.ReceiveOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do we need pointer semantics here (and in the constructors)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you notice the changes on sender file require a pointer since the library used assumes that if nil is passed default is assumed. If in the future the library does the same for the receiver it will be prepared to it. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine, you can always use the copied value with &var - but make a copy of the provided struct (to avoid races/bugs) when calling New...()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, gone back to not using pointer for this case

@cx-joses
Copy link
Author

cx-joses commented Apr 24, 2024

Thx for the quick fix! Question: is the reason to bump to go 1.22 due to the amqp bump or actually not needed?

@embano1 actually it was not supposed to be done. I was thinking of upgrading it all but there is no need and required more changes.

@embano1
Copy link
Member

embano1 commented Apr 24, 2024

Thx, I still see the bumps though?

@cx-joses
Copy link
Author

Thx, I still see the bumps though?

@embano1 I actually upgraded to 1.21 since its the version referred on build steps and others. do you see any issue in doing so?

@cx-joses cx-joses requested a review from embano1 April 24, 2024 17:11
@cx-joses cx-joses changed the title #1039 - upgrade go to 1.22; upgrade packages; migrate azure/go-amqp to 1.0.5 #1039 Migrate azure/go-amqp to version 1.0.5 Apr 24, 2024
@embano1
Copy link
Member

embano1 commented Apr 24, 2024

@embano1 I actually upgraded to 1.21 since its the version referred on build steps and others. do you see any issue in doing so?

IMHO we want to keep 1.18 so we don't introduce additional changes/features that might block users compiling with older go versions. The README states:

Note: Supported go version: 1.18+

@cx-joses
Copy link
Author

@embano1 I actually upgraded to 1.21 since its the version referred on build steps and others. do you see any issue in doing so?

IMHO we want to keep 1.18 so we don't introduce additional changes/features that might block users compiling with older go versions. The README states:

Note: Supported go version: 1.18+

understood, you are absolutely right! reverted it all to 1.18 again! thanks

}
return env, strings.TrimPrefix(u.Path, "/"), opts
}

func main() {
host, node, opts := sampleConfig()
p, err := ceamqp.NewProtocol(host, node, []amqp.ConnOption{}, []amqp.SessionOption{}, opts...)
p, err := ceamqp.NewProtocol(context.Background(), host, node, opts, &amqp.SessionOptions{},
&amqp.SenderOptions{}, &amqp.ReceiverOptions{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be much nicer if those would not be pointers IMHO

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it use the struct instead of pointers. thanks

Signed-off-by: Jose Silva <jose.silva@checkmarx.com>
@@ -35,54 +30,60 @@ type Protocol struct {
}

// NewProtocolFromClient creates a new amqp transport.
func NewProtocolFromClient(client *amqp.Client, session *amqp.Session, queue string, opts ...Option) (*Protocol, error) {
func NewProtocolFromClient(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: are we ok with this breaking change on this signature? I understand why we technically might not need options anymore (since those are now structs), but you might want to keep the options pattern to not break this signature and allow for future expansions. You could introduce a new option to set sender/receiver options on the protocol.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are you worried that those two structs are always needed and thus an options pattern doesn't really apply?

return t, nil
}

// NewProtocol creates a new amqp transport.
func NewProtocol(server, queue string, connOption []amqp.ConnOption, sessionOption []amqp.SessionOption, opts ...Option) (*Protocol, error) {
client, err := amqp.Dial(server, connOption...)
func NewProtocol(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question as above

for _, o := range options {
o(s)
}
func NewSender(amqpSender *amqp.Sender, options *amqp.SendOptions) protocol.Sender {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: inconsistent with other functions due to pointer

Suggested change
func NewSender(amqpSender *amqp.Sender, options *amqp.SendOptions) protocol.Sender {
func NewSender(amqpSender *amqp.Sender, options amqp.SendOptions) protocol.Sender {

}
return env, strings.TrimPrefix(u.Path, "/"), opts
}

func main() {
host, node, opts := sampleConfig()
p, err := ceamqp.NewProtocol(host, node, []amqp.ConnOption{}, []amqp.SessionOption{}, opts...)
p, err := ceamqp.NewProtocol(context.Background(), host, node, opts, amqp.SessionOptions{},
amqp.SenderOptions{}, amqp.ReceiverOptions{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting: so we don't need those options, which goes back to my comment on keeping functional options pattern

@@ -51,7 +53,8 @@ type Example struct {

func main() {
host, node, opts := sampleConfig()
p, err := ceamqp.NewProtocol(host, node, []amqp.ConnOption{}, []amqp.SessionOption{}, opts...)
p, err := ceamqp.NewProtocol(context.Background(), host, node, opts, amqp.SessionOptions{}, amqp.SenderOptions{},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see other comment on options

require.NoError(t, err)
return client, session, addr
senderOpts = amqp.SenderOptions{}
require.NotNil(t, senderOpts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this testing?

require.NotNil(t, senderOpts)
receiverOpts = &amqp.ReceiverOptions{}
require.NotNil(t, receiverOpts)
return client, session, addr, senderOpts, receiverOpts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unless needed, don't return pointers but structs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the other function you used structs on return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support https://github.com/Azure/go-amqp stable version
2 participants