@@ -89,9 +89,7 @@ export interface XdsConfig {
8989}
9090
9191export interface XdsConfigWatcher {
92- onUpdate ( xdsConfig : XdsConfig ) : void ;
93- onError ( context : string , status : StatusObject ) : void ;
94- onResourceDoesNotExist ( context : string ) : void ;
92+ onUpdate ( xdsConfig : StatusOr < XdsConfig > ) : void ;
9593}
9694
9795interface AggregateClusterInfo {
@@ -394,7 +392,13 @@ export class XdsDependencyManager {
394392 * not already provided a ServiceConfig for the upper layer to use */
395393 if ( ! this . latestListener ) {
396394 this . trace ( 'Resolution error due to xDS client transient error ' + error . details ) ;
397- this . watcher . onError ( `Listener ${ listenerResourceName } ` , error ) ;
395+ this . watcher . onUpdate ( {
396+ ok : false ,
397+ error : {
398+ ...error ,
399+ details : `Listener ${ listenerResourceName } : ${ error . details } `
400+ }
401+ } ) ;
398402 }
399403 } ,
400404 onResourceDoesNotExist : ( ) => {
@@ -408,11 +412,24 @@ export class XdsDependencyManager {
408412 } ,
409413 onError : ( error : StatusObject ) => {
410414 if ( ! this . latestRouteConfiguration ) {
411- this . watcher . onError ( `RouteConfiguration ${ this . latestRouteConfigName } ` , error ) ;
415+ this . watcher . onUpdate ( {
416+ ok : false ,
417+ error : {
418+ ...error ,
419+ details : `RouteConfiguration ${ this . latestRouteConfigName } : ${ error . details } `
420+ }
421+ } ) ;
412422 }
413423 } ,
414424 onResourceDoesNotExist : ( ) => {
415- this . watcher . onResourceDoesNotExist ( `RouteConfiguration ${ this . latestRouteConfigName } ` ) ;
425+ this . watcher . onUpdate ( {
426+ ok : false ,
427+ error : {
428+ code : status . UNAVAILABLE ,
429+ details : `RouteConfiguration ${ this . latestRouteConfigName } does not exist` ,
430+ metadata : new Metadata ( )
431+ }
432+ } ) ;
416433 this . clusterRoots = [ ] ;
417434 this . pruneOrphanClusters ( ) ;
418435 }
@@ -434,8 +451,14 @@ export class XdsDependencyManager {
434451 this . clusterRoots = [ ] ;
435452 this . pruneOrphanClusters ( ) ;
436453 }
437- this . watcher . onResourceDoesNotExist ( `Listener ${ this . listenerResourceName } ` ) ;
438-
454+ this . watcher . onUpdate ( {
455+ ok : false ,
456+ error : {
457+ code : status . UNAVAILABLE ,
458+ details : `Listener ${ this . listenerResourceName } does not exist` ,
459+ metadata : new Metadata ( )
460+ }
461+ } ) ;
439462 }
440463
441464 private maybeSendUpdate ( ) {
@@ -491,7 +514,7 @@ export class XdsDependencyManager {
491514 } ) ;
492515 }
493516 }
494- this . watcher . onUpdate ( update ) ;
517+ this . watcher . onUpdate ( { ok : true , value : update } ) ;
495518 }
496519
497520 private addCluster ( clusterName : string ) {
@@ -763,10 +786,13 @@ export class XdsDependencyManager {
763786 if ( ! virtualHost ) {
764787 this . clusterRoots = [ ] ;
765788 this . pruneOrphanClusters ( ) ;
766- this . watcher . onError ( `RouteConfiguration ${ routeConfig . name } ` , {
767- code : status . UNAVAILABLE ,
768- details : `No matching route found for ${ this . dataPlaneAuthority } ` ,
769- metadata : new Metadata ( )
789+ this . watcher . onUpdate ( {
790+ ok : false ,
791+ error : {
792+ code : status . UNAVAILABLE ,
793+ details : `RouteConfiguration ${ routeConfig . name } : No matching route found for ${ this . dataPlaneAuthority } ` ,
794+ metadata : new Metadata ( )
795+ }
770796 } ) ;
771797 // Report error
772798 return ;
0 commit comments