@@ -89,9 +89,7 @@ export interface XdsConfig {
89
89
}
90
90
91
91
export 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 ;
95
93
}
96
94
97
95
interface AggregateClusterInfo {
@@ -394,7 +392,13 @@ export class XdsDependencyManager {
394
392
* not already provided a ServiceConfig for the upper layer to use */
395
393
if ( ! this . latestListener ) {
396
394
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
+ } ) ;
398
402
}
399
403
} ,
400
404
onResourceDoesNotExist : ( ) => {
@@ -408,11 +412,24 @@ export class XdsDependencyManager {
408
412
} ,
409
413
onError : ( error : StatusObject ) => {
410
414
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
+ } ) ;
412
422
}
413
423
} ,
414
424
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
+ } ) ;
416
433
this . clusterRoots = [ ] ;
417
434
this . pruneOrphanClusters ( ) ;
418
435
}
@@ -434,8 +451,14 @@ export class XdsDependencyManager {
434
451
this . clusterRoots = [ ] ;
435
452
this . pruneOrphanClusters ( ) ;
436
453
}
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
+ } ) ;
439
462
}
440
463
441
464
private maybeSendUpdate ( ) {
@@ -491,7 +514,7 @@ export class XdsDependencyManager {
491
514
} ) ;
492
515
}
493
516
}
494
- this . watcher . onUpdate ( update ) ;
517
+ this . watcher . onUpdate ( { ok : true , value : update } ) ;
495
518
}
496
519
497
520
private addCluster ( clusterName : string ) {
@@ -763,10 +786,13 @@ export class XdsDependencyManager {
763
786
if ( ! virtualHost ) {
764
787
this . clusterRoots = [ ] ;
765
788
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
+ }
770
796
} ) ;
771
797
// Report error
772
798
return ;
0 commit comments