@@ -72,27 +72,29 @@ public async ValueTask<IConnection> FindConnectionForTopic(string topic, Cancell
7272 var lookup = new CommandLookupTopic
7373 {
7474 Topic = topic ,
75- Authoritative = false ,
76- AdvertisedListenerName = _listenerName
75+ Authoritative = false
7776 } ;
7877
78+ if ( _listenerName is not null )
79+ lookup . AdvertisedListenerName = _listenerName ;
80+
7981 var physicalUrl = _serviceUrl ;
8082
8183 while ( true )
8284 {
8385 var connection = await GetConnection ( physicalUrl , cancellationToken ) . ConfigureAwait ( false ) ;
8486 var response = await connection . Send ( lookup , cancellationToken ) . ConfigureAwait ( false ) ;
8587
86- response . Expect ( BaseCommand . Type . LookupResponse ) ;
88+ response . Expect ( BaseCommand . Types . Type . LookupResponse ) ;
8789
88- if ( response . LookupTopicResponse . Response == CommandLookupTopicResponse . LookupType . Failed )
90+ if ( response . LookupTopicResponse . Response == CommandLookupTopicResponse . Types . LookupType . Failed )
8991 response . LookupTopicResponse . Throw ( ) ;
9092
9193 lookup . Authoritative = response . LookupTopicResponse . Authoritative ;
9294
9395 var lookupResponseServiceUrl = new Uri ( GetBrokerServiceUrl ( response . LookupTopicResponse ) ) ;
9496
95- if ( response . LookupTopicResponse . Response == CommandLookupTopicResponse . LookupType . Redirect || ! response . LookupTopicResponse . Authoritative )
97+ if ( response . LookupTopicResponse . Response == CommandLookupTopicResponse . Types . LookupType . Redirect || ! response . LookupTopicResponse . Authoritative )
9698 {
9799 physicalUrl = lookupResponseServiceUrl ;
98100 continue ;
@@ -155,7 +157,7 @@ private async Task<Connection> EstablishNewConnection(PulsarUrl url, Cancellatio
155157 var connection = Connection . Connect ( new PulsarStream ( stream ) , _authentication , _keepAliveInterval , _closeInactiveConnectionsInterval ) ;
156158 _ = connection . State . OnStateChangeFrom ( ConnectionState . Connected , CancellationToken . None ) . AsTask ( ) . ContinueWith ( t => DisposeConnection ( url , connection ) , CancellationToken . None ) ;
157159 var response = await connection . Send ( commandConnect , cancellationToken ) . ConfigureAwait ( false ) ;
158- response . Expect ( BaseCommand . Type . Connected ) ;
160+ response . Expect ( BaseCommand . Types . Type . Connected ) ;
159161 _connections [ url ] = connection ;
160162 connection . MaxMessageSize = response . Connected . MaxMessageSize ;
161163 return connection ;
@@ -169,19 +171,28 @@ private async ValueTask DisposeConnection(PulsarUrl serviceUrl, Connection conne
169171
170172 private static CommandConnect WithProxyToBroker ( CommandConnect commandConnect , Uri logicalUrl )
171173 {
172- return new CommandConnect
174+ var command = new CommandConnect
173175 {
174- AuthData = commandConnect . ShouldSerializeAuthData ( ) ? commandConnect . AuthData : null ,
175- AuthMethod = commandConnect . ShouldSerializeAuthMethod ( ) ? commandConnect . AuthMethod : AuthMethod . AuthMethodNone ,
176- AuthMethodName = commandConnect . ShouldSerializeAuthMethodName ( ) ? commandConnect . AuthMethodName : null ,
177176 ClientVersion = commandConnect . ClientVersion ,
178- OriginalPrincipal = commandConnect . ShouldSerializeOriginalPrincipal ( ) ? commandConnect . OriginalPrincipal : null ,
179177 ProtocolVersion = commandConnect . ProtocolVersion ,
180- OriginalAuthData = commandConnect . ShouldSerializeOriginalAuthData ( ) ? commandConnect . OriginalAuthData : null ,
181- OriginalAuthMethod = commandConnect . ShouldSerializeOriginalAuthMethod ( ) ? commandConnect . OriginalAuthMethod : null ,
182178 ProxyToBrokerUrl = $ "{ logicalUrl . Host } :{ logicalUrl . Port } ",
183179 FeatureFlags = commandConnect . FeatureFlags
184180 } ;
181+
182+ if ( commandConnect . HasAuthData )
183+ command . AuthData = commandConnect . AuthData ;
184+ if ( commandConnect . HasAuthMethod )
185+ command . AuthMethod = commandConnect . AuthMethod ;
186+ if ( commandConnect . HasAuthMethodName )
187+ command . AuthMethodName = commandConnect . AuthMethodName ;
188+ if ( command . HasOriginalPrincipal )
189+ command . OriginalPrincipal = commandConnect . OriginalPrincipal ;
190+ if ( command . HasOriginalAuthData )
191+ command . OriginalAuthData = commandConnect . OriginalAuthData ;
192+ if ( command . HasOriginalAuthMethod )
193+ command . OriginalAuthMethod = commandConnect . OriginalAuthMethod ;
194+
195+ return command ;
185196 }
186197
187198 private sealed class PulsarUrl : IEquatable < PulsarUrl >
@@ -226,15 +237,15 @@ public async ValueTask<uint> GetNumberOfPartitions(string topic, CancellationTok
226237 var commandPartitionedMetadata = new CommandPartitionedTopicMetadata { Topic = topic } ;
227238 var response = await connection . Send ( commandPartitionedMetadata , cancellationToken ) . ConfigureAwait ( false ) ;
228239
229- response . Expect ( BaseCommand . Type . PartitionedMetadataResponse ) ;
240+ response . Expect ( BaseCommand . Types . Type . PartitionedMetadataResponse ) ;
230241
231- if ( response . PartitionMetadataResponse . Response == CommandPartitionedTopicMetadataResponse . LookupType . Failed )
242+ if ( response . PartitionMetadataResponse . Response == CommandPartitionedTopicMetadataResponse . Types . LookupType . Failed )
232243 response . PartitionMetadataResponse . Throw ( ) ;
233244
234245 return response . PartitionMetadataResponse . Partitions ;
235246 }
236247
237- public async ValueTask < IEnumerable < string > > GetTopicsOfNamespace ( CommandGetTopicsOfNamespace . Mode mode , Regex topicsPattern , CancellationToken cancellationToken = default )
248+ public async ValueTask < IEnumerable < string > > GetTopicsOfNamespace ( CommandGetTopicsOfNamespace . Types . Mode mode , Regex topicsPattern , CancellationToken cancellationToken = default )
238249 {
239250 var topicUriPattern = new Regex ( @"^(persistent|non-persistent)://([^/]+)/([^/]+)/(.+)$" , RegexOptions . Compiled ) ;
240251
@@ -251,29 +262,29 @@ public async ValueTask<IEnumerable<string>> GetTopicsOfNamespace(CommandGetTopic
251262 if ( ! string . IsNullOrEmpty ( persistence ) )
252263 {
253264 if ( persistence . Equals ( "persistent" ) )
254- mode = CommandGetTopicsOfNamespace . Mode . Persistent ;
265+ mode = CommandGetTopicsOfNamespace . Types . Mode . Persistent ;
255266 else
256- mode = CommandGetTopicsOfNamespace . Mode . NonPersistent ;
267+ mode = CommandGetTopicsOfNamespace . Types . Mode . NonPersistent ;
257268 }
258269
259270 var getTopicsOfNamespace = new CommandGetTopicsOfNamespace
260271 {
261- mode = mode ,
272+ Mode = mode ,
262273 Namespace = $ "{ tenant } /{ ns } ",
263274 TopicsPattern = patternString
264275 } ;
265276
266277 var connection = await GetConnection ( _serviceUrl , cancellationToken ) . ConfigureAwait ( false ) ;
267278 var response = await connection . Send ( getTopicsOfNamespace , cancellationToken ) . ConfigureAwait ( false ) ;
268279
269- response . Expect ( BaseCommand . Type . GetTopicsOfNamespaceResponse ) ;
280+ response . Expect ( BaseCommand . Types . Type . GetTopicsOfNamespaceResponse ) ;
270281
271- if ( response . getTopicsOfNamespaceResponse . Filtered )
272- return response . getTopicsOfNamespaceResponse . Topics ;
282+ if ( response . GetTopicsOfNamespaceResponse . Filtered )
283+ return response . GetTopicsOfNamespaceResponse . Topics ;
273284
274285 var topics = new List < string > ( ) ;
275286
276- foreach ( var topic in response . getTopicsOfNamespaceResponse . Topics )
287+ foreach ( var topic in response . GetTopicsOfNamespaceResponse . Topics )
277288 {
278289 if ( topicsPattern . Match ( topic ) . Success )
279290 topics . Add ( topic ) ;
0 commit comments