@@ -15,6 +15,7 @@ import (
1515 "github.com/Azure/azure-sdk-for-go/sdk/azcore"
1616 "github.com/Azure/azure-sdk-for-go/sdk/internal/log"
1717 "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/internal"
18+ "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/internal/amqpwrap"
1819 "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/internal/exported"
1920)
2021
@@ -28,15 +29,10 @@ type Client struct {
2829 // PR: https://github.com/Azure/azure-sdk-for-go/pull/16847
2930 linkCounter uint64
3031
31- linksMu * sync.Mutex
32- links map [uint64 ]internal.Closeable
33- creds clientCreds
34- namespace interface {
35- // used internally by `Client`
36- internal.NamespaceWithNewAMQPLinks
37- // for child clients
38- internal.NamespaceForAMQPLinks
39- }
32+ linksMu * sync.Mutex
33+ links map [uint64 ]amqpwrap.Closeable
34+ creds clientCreds
35+ namespace internal.NamespaceForAMQPLinks
4036 retryOptions RetryOptions
4137
4238 // acceptNextTimeout controls how long the session accept can take before
@@ -85,7 +81,9 @@ func NewClient(fullyQualifiedNamespace string, credential azcore.TokenCredential
8581 return newClientImpl (clientCreds {
8682 credential : credential ,
8783 fullyQualifiedNamespace : fullyQualifiedNamespace ,
88- }, options )
84+ }, clientImplArgs {
85+ ClientOptions : options ,
86+ })
8987}
9088
9189// NewClientFromConnectionString creates a new Client for a Service Bus namespace using a connection string.
@@ -105,7 +103,9 @@ func NewClientFromConnectionString(connectionString string, options *ClientOptio
105103
106104 return newClientImpl (clientCreds {
107105 connectionString : connectionString ,
108- }, options )
106+ }, clientImplArgs {
107+ ClientOptions : options ,
108+ })
109109}
110110
111111// Next overloads (ie, credential sticks with the client)
@@ -120,11 +120,16 @@ type clientCreds struct {
120120 credential azcore.TokenCredential
121121}
122122
123- func newClientImpl (creds clientCreds , options * ClientOptions ) (* Client , error ) {
123+ type clientImplArgs struct {
124+ ClientOptions * ClientOptions
125+ NSOptions []internal.NamespaceOption
126+ }
127+
128+ func newClientImpl (creds clientCreds , args clientImplArgs ) (* Client , error ) {
124129 client := & Client {
125130 linksMu : & sync.Mutex {},
126131 creds : creds ,
127- links : map [uint64 ]internal .Closeable {},
132+ links : map [uint64 ]amqpwrap .Closeable {},
128133 }
129134
130135 var err error
@@ -140,24 +145,26 @@ func newClientImpl(creds clientCreds, options *ClientOptions) (*Client, error) {
140145 nsOptions = append (nsOptions , option )
141146 }
142147
143- if options != nil {
144- client .retryOptions = options .RetryOptions
148+ if args . ClientOptions != nil {
149+ client .retryOptions = args . ClientOptions .RetryOptions
145150
146- if options .TLSConfig != nil {
147- nsOptions = append (nsOptions , internal .NamespaceWithTLSConfig (options .TLSConfig ))
151+ if args . ClientOptions .TLSConfig != nil {
152+ nsOptions = append (nsOptions , internal .NamespaceWithTLSConfig (args . ClientOptions .TLSConfig ))
148153 }
149154
150- if options .NewWebSocketConn != nil {
151- nsOptions = append (nsOptions , internal .NamespaceWithWebSocket (options .NewWebSocketConn ))
155+ if args . ClientOptions .NewWebSocketConn != nil {
156+ nsOptions = append (nsOptions , internal .NamespaceWithWebSocket (args . ClientOptions .NewWebSocketConn ))
152157 }
153158
154- if options .ApplicationID != "" {
155- nsOptions = append (nsOptions , internal .NamespaceWithUserAgent (options .ApplicationID ))
159+ if args . ClientOptions .ApplicationID != "" {
160+ nsOptions = append (nsOptions , internal .NamespaceWithUserAgent (args . ClientOptions .ApplicationID ))
156161 }
157162
158- nsOptions = append (nsOptions , internal .NamespaceWithRetryOptions (options .RetryOptions ))
163+ nsOptions = append (nsOptions , internal .NamespaceWithRetryOptions (args . ClientOptions .RetryOptions ))
159164 }
160165
166+ nsOptions = append (nsOptions , args .NSOptions ... )
167+
161168 client .namespace , err = internal .NewNamespace (nsOptions ... )
162169 return client , err
163170}
@@ -303,7 +310,7 @@ func (client *Client) AcceptNextSessionForSubscription(ctx context.Context, topi
303310// Close closes the current connection Service Bus as well as any Senders or Receivers created
304311// using this client.
305312func (client * Client ) Close (ctx context.Context ) error {
306- var links []internal .Closeable
313+ var links []amqpwrap .Closeable
307314
308315 client .linksMu .Lock ()
309316
@@ -319,7 +326,7 @@ func (client *Client) Close(ctx context.Context) error {
319326 }
320327 }
321328
322- return client .namespace .Close (ctx , true )
329+ return client .namespace .Close (true )
323330}
324331
325332func (client * Client ) acceptNextSessionForEntity (ctx context.Context , entity entity , options * SessionReceiverOptions ) (* SessionReceiver , error ) {
@@ -347,7 +354,7 @@ func (client *Client) acceptNextSessionForEntity(ctx context.Context, entity ent
347354 return sessionReceiver , nil
348355}
349356
350- func (client * Client ) addCloseable (id uint64 , closeable internal .Closeable ) {
357+ func (client * Client ) addCloseable (id uint64 , closeable amqpwrap .Closeable ) {
351358 client .linksMu .Lock ()
352359 client .links [id ] = closeable
353360 client .linksMu .Unlock ()
0 commit comments