Skip to content

Commit dc0094d

Browse files
committed
Send initial message at the beginning of a new LRS stream, and send node in initial message
1 parent 978f4cb commit dc0094d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/grpc-js-xds/src/xds-client.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ class LrsCallState {
676676
this.handleStreamStatus(status);
677677
});
678678
call.on('error', () => {});
679+
this.sendStats();
679680
}
680681

681682
private handleStreamStatus(status: StatusObject) {
@@ -714,10 +715,13 @@ class LrsCallState {
714715
}
715716

716717
private sendLrsMessage(clusterStats: ClusterStats[]) {
717-
this.call.write({
718-
node: this.sentInitialMessage ? this.node : null,
718+
const request: LoadStatsRequest = {
719+
node: this.sentInitialMessage ? null : this.node,
719720
cluster_stats: clusterStats
720-
});
721+
};
722+
this.client.trace('Sending LRS message ' + JSON.stringify(request, undefined, 2));
723+
this.call.write(request);
724+
this.sentInitialMessage = true;
721725
}
722726

723727
private get latestLrsSettings() {
@@ -791,7 +795,6 @@ class LrsCallState {
791795
}
792796
}
793797
}
794-
this.client.trace('Sending LRS stats ' + JSON.stringify(clusterStats, undefined, 2));
795798
this.sendLrsMessage(clusterStats);
796799

797800
}

0 commit comments

Comments
 (0)