@@ -121,7 +121,7 @@ impl TranslatorSv2 {
121121
122122 info ! ( "Initializing upstream connection..." ) ;
123123
124- let init_result = match self
124+ let negotiated_extensions = match self
125125 . initialize_upstream (
126126 & mut upstream_addresses,
127127 channel_manager_to_upstream_receiver. clone ( ) ,
@@ -135,7 +135,7 @@ impl TranslatorSv2 {
135135 )
136136 . await
137137 {
138- Ok ( result ) => result ,
138+ Ok ( extensions ) => extensions ,
139139 Err ( e) => {
140140 error ! ( "Failed to initialize any upstream connection: {e:?}" ) ;
141141 return ;
@@ -153,7 +153,7 @@ impl TranslatorSv2 {
153153 status_sender. clone ( ) ,
154154 self . config . supported_extensions . clone ( ) ,
155155 self . config . required_extensions . clone ( ) ,
156- init_result . negotiated_extensions ,
156+ negotiated_extensions,
157157 ) ) ;
158158
159159 info ! ( "Launching ChannelManager tasks..." ) ;
@@ -283,10 +283,10 @@ impl TranslatorSv2 {
283283 sv1_server. clone( ) ,
284284 self . config. required_extensions. clone( ) ,
285285 ) . await {
286- Ok ( fallback_result ) => {
286+ Ok ( negotiated_extensions ) => {
287287 info!(
288288 "Upstream restarted successfully with extensions: {:?}" ,
289- fallback_result . negotiated_extensions
289+ negotiated_extensions
290290 ) ;
291291
292292 channel_manager = Arc :: new( ChannelManager :: new(
@@ -297,7 +297,7 @@ impl TranslatorSv2 {
297297 status_sender. clone( ) ,
298298 self . config. supported_extensions. clone( ) ,
299299 self . config. required_extensions. clone( ) ,
300- fallback_result . negotiated_extensions,
300+ negotiated_extensions,
301301 ) ) ;
302302 }
303303 Err ( e) => {
@@ -409,7 +409,7 @@ impl TranslatorSv2 {
409409 /// to avoid hammering known-bad endpoints during failover.
410410 ///
411411 /// # Returns
412- /// * `Ok(UpstreamInitResult )` - Contains the negotiated extensions to be passed to ChannelManager
412+ /// * `Ok(Vec<u16> )` - The negotiated extensions to be passed to ChannelManager
413413 /// * `Err(TproxyErrorKind)` - All upstreams failed
414414 #[ allow( clippy:: too_many_arguments) ]
415415 pub async fn initialize_upstream (
@@ -423,7 +423,7 @@ impl TranslatorSv2 {
423423 task_manager : Arc < TaskManager > ,
424424 sv1_server_instance : Arc < Sv1Server > ,
425425 required_extensions : Vec < u16 > ,
426- ) -> Result < UpstreamInitResult , TproxyErrorKind > {
426+ ) -> Result < Vec < u16 > , TproxyErrorKind > {
427427 const MAX_RETRIES : usize = 3 ;
428428 let upstream_len = upstreams. len ( ) ;
429429 for ( i, upstream_entry) in upstreams. iter_mut ( ) . enumerate ( ) {
@@ -458,10 +458,10 @@ impl TranslatorSv2 {
458458 )
459459 . await
460460 {
461- Ok ( init_result ) => {
461+ Ok ( negotiated_extensions ) => {
462462 info ! (
463463 "Extension negotiation complete. Negotiated extensions: {:?}" ,
464- init_result . negotiated_extensions
464+ negotiated_extensions
465465 ) ;
466466
467467 // Now that extensions are negotiated, start the SV1 server
@@ -480,7 +480,7 @@ impl TranslatorSv2 {
480480 }
481481
482482 upstream_entry. tried_or_flagged = true ;
483- return Ok ( init_result ) ;
483+ return Ok ( negotiated_extensions ) ;
484484 }
485485 Err ( e) => {
486486 warn ! (
@@ -504,14 +504,6 @@ impl TranslatorSv2 {
504504 }
505505}
506506
507- /// Result of successful upstream initialization.
508- /// Contains the negotiated extensions that should be passed to the ChannelManager.
509- pub struct UpstreamInitResult {
510- /// Extensions that were successfully negotiated with the upstream server.
511- /// This should be stored in the ChannelManager before starting the SV1 server.
512- pub negotiated_extensions : Vec < u16 > ,
513- }
514-
515507// Attempts to initialize a single upstream.
516508#[ allow( clippy:: too_many_arguments) ]
517509#[ cfg_attr( not( test) , hotpath:: measure) ]
@@ -524,7 +516,7 @@ async fn try_initialize_upstream(
524516 status_sender : Sender < Status > ,
525517 task_manager : Arc < TaskManager > ,
526518 required_extensions : Vec < u16 > ,
527- ) -> Result < UpstreamInitResult , TproxyErrorKind > {
519+ ) -> Result < Vec < u16 > , TproxyErrorKind > {
528520 let upstream = Upstream :: new (
529521 upstream_addr,
530522 upstream_to_channel_manager_sender,
@@ -536,18 +528,15 @@ async fn try_initialize_upstream(
536528 )
537529 . await ?;
538530
539- let negotiated_extensions = upstream
531+ upstream
540532 . start (
541533 cancellation_token,
542534 fallback_coordinator,
543535 status_sender,
544536 task_manager,
545537 )
546- . await ?;
547-
548- Ok ( UpstreamInitResult {
549- negotiated_extensions,
550- } )
538+ . await
539+ . map_err ( |e| e. kind )
551540}
552541
553542/// Defines the operational mode for Translator Proxy.
0 commit comments