Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

add connection open properties #31

Merged
merged 1 commit into from
Feb 14, 2018

Conversation

devigned
Copy link
Contributor

@devigned devigned commented Feb 13, 2018

Resolves: #28

  • add properties field to the conn struct
  • add ConnOption to configure properties
  • set properties on the open performative
  • fix integration tests to target the exact API version of the Azure Service Bus management lib to ensure no future breaking changes

Copy link
Owner

@vcabbage vcabbage left a comment

Choose a reason for hiding this comment

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

I left a few notes, but overall looks good 👍

conn.go Outdated
c.properties = make(map[symbol]interface{})
}
sym := symbol(key)
c.properties[sym] = value
Copy link
Owner

Choose a reason for hiding this comment

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

Simplify to c.properties[symbol(key)] = value.

conn.go Outdated
@@ -128,6 +128,18 @@ func ConnMaxSessions(n int) ConnOption {
}
}

// ConnProperty sets an entry in the connection properties
Copy link
Owner

Choose a reason for hiding this comment

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

// ConnProperty sets an entry in the connection properties map sent to the server.
//
// This option can be used multiple times.

conn.go Outdated
@@ -198,6 +211,7 @@ func newConn(netConn net.Conn, opts ...ConnOption) (*conn, error) {
delSession: make(chan *Session),
txFrame: make(chan frame),
txDone: make(chan struct{}),
properties: make(map[symbol]interface{}),
Copy link
Owner

Choose a reason for hiding this comment

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

We want properties to be nil when none are specified, so this line is unnecessary.

conn_test.go Outdated
if c.properties[symbol(key)] != value {
t.Errorf("conn property was not set to key \"%s\" and value \"%s\"", key, value)
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not a big fan of tests that do something relatively simple and then check that it did the thing.

I'd rewrite this as a table test ensuring different sets of options produce the correct results. I'll create an issue to track adding that sort of test unless you'd particularly like to take that on in this PR (there's no expectation on my part that you do).

@@ -18,7 +18,7 @@ import (
"testing"
"time"

"github.com/Azure/azure-sdk-for-go/arm/servicebus"
"github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus"
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for fixing this 👍

conn_test.go Outdated
}

if c.properties[symbol(key)] != value {
t.Errorf("conn property was not set to key \"%s\" and value \"%s\"", key, value)
Copy link
Owner

Choose a reason for hiding this comment

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

Just FYI, the %q formatter is handy when you want to quote strings. It's particularly useful when comparing strings that may have unprintable characters. https://play.golang.org/p/xx2QI3_4Irr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that's fancy. Thanks for spreading the knowledge.

conn_test.go Outdated
value := "propValue"
err := ConnProperty(key, value)(c)
if err != nil {
t.Error(fmt.Sprintf("%+v", err))
Copy link
Owner

Choose a reason for hiding this comment

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

I don't know how this sort of thing ended up in the other tests, but it should just be t.Errorf("%+v", err). I need to correct my usages.

vcabbage added a commit that referenced this pull request Feb 14, 2018
… error.

* Adds exported `ErrConnClosed`, `ErrSessionClosed`, and `ErrLinkClosed`
  indicating a library consumer requested close.
* Some refactoring to conn close logic to remove race condition where
  another component could acquire conn.errMu after conn.mux releases it
  but before conn.close acquires it.
* Copied integration test fixes from #31.

Fixes #33
vcabbage added a commit that referenced this pull request Feb 14, 2018
… error. (#34)

* Adds exported `ErrConnClosed`, `ErrSessionClosed`, and `ErrLinkClosed`
  indicating a library consumer requested close.
* Some refactoring to conn close logic to remove race condition where
  another component could acquire conn.errMu after conn.mux releases it
  but before conn.close acquires it.
* Copied integration test fixes from #31.

Fixes #33
@devigned
Copy link
Contributor Author

@vcabbage I added an error check for empty keys. I don't think an empty symbol makes sense.

@vcabbage vcabbage merged commit ccafaa7 into vcabbage:master Feb 14, 2018
@vcabbage
Copy link
Owner

Thanks!

@devigned
Copy link
Contributor Author

My pleasure. Thank you for the feedback and the quick merge.

@devigned devigned deleted the feature/conn-props branch February 14, 2018 19:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connection Open Properties
2 participants