mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Register xds listener with channelz
This commit is contained in:
parent
7d99c4a7aa
commit
1e28a04330
@ -628,8 +628,9 @@ export class XdsServer extends Server {
|
||||
if (!hostPort || !isValidIpPort(hostPort)) {
|
||||
throw new Error(`Listening port string must have the format IP:port with non-zero port, got ${port}`);
|
||||
}
|
||||
const channelzRef = this.experimentalRegisterListenerToChannelz({host: hostPort.host, port: hostPort.port!});
|
||||
const configParameters: ConfigParameters = {
|
||||
createConnectionInjector: (credentials) => this.createConnectionInjector(credentials),
|
||||
createConnectionInjector: (credentials) => this.experimentalCreateConnectionInjectorWithChannelzRef(credentials, channelzRef),
|
||||
drainGraceTimeMs: this.drainGraceTimeMs,
|
||||
listenerResourceNameTemplate: this.listenerResourceNameTemplate,
|
||||
xdsClient: this.xdsClient
|
||||
|
||||
@ -539,7 +539,12 @@ export class Server {
|
||||
throw new Error('Not implemented. Use bindAsync() instead');
|
||||
}
|
||||
|
||||
private registerListenerToChannelz(boundAddress: SubchannelAddress) {
|
||||
/**
|
||||
* This API is experimental, so API stability is not guaranteed across minor versions.
|
||||
* @param boundAddress
|
||||
* @returns
|
||||
*/
|
||||
protected experimentalRegisterListenerToChannelz(boundAddress: SubchannelAddress) {
|
||||
return registerChannelzSocket(
|
||||
subchannelAddressToString(boundAddress),
|
||||
() => {
|
||||
@ -649,7 +654,7 @@ export class Server {
|
||||
};
|
||||
}
|
||||
|
||||
const channelzRef = this.registerListenerToChannelz(
|
||||
const channelzRef = this.experimentalRegisterListenerToChannelz(
|
||||
boundSubchannelAddress
|
||||
);
|
||||
this.listenerChildrenTracker.refChild(channelzRef);
|
||||
@ -945,15 +950,17 @@ export class Server {
|
||||
);
|
||||
}
|
||||
|
||||
createConnectionInjector(credentials: ServerCredentials): ConnectionInjector {
|
||||
/**
|
||||
* This API is experimental, so API stability is not guaranteed across minor versions.
|
||||
* @param credentials
|
||||
* @param channelzRef
|
||||
* @returns
|
||||
*/
|
||||
protected experimentalCreateConnectionInjectorWithChannelzRef(credentials: ServerCredentials, channelzRef: SocketRef) {
|
||||
if (credentials === null || !(credentials instanceof ServerCredentials)) {
|
||||
throw new TypeError('creds must be a ServerCredentials object');
|
||||
}
|
||||
const server = this.createHttp2Server(credentials);
|
||||
const channelzRef = this.registerInjectorToChannelz();
|
||||
if (this.channelzEnabled) {
|
||||
this.listenerChildrenTracker.refChild(channelzRef);
|
||||
}
|
||||
const sessionsSet: Set<http2.ServerHttp2Session> = new Set();
|
||||
this.http2Servers.set(server, {
|
||||
channelzRef: channelzRef,
|
||||
@ -982,6 +989,17 @@ export class Server {
|
||||
};
|
||||
}
|
||||
|
||||
createConnectionInjector(credentials: ServerCredentials): ConnectionInjector {
|
||||
if (credentials === null || !(credentials instanceof ServerCredentials)) {
|
||||
throw new TypeError('creds must be a ServerCredentials object');
|
||||
}
|
||||
const channelzRef = this.registerInjectorToChannelz();
|
||||
if (this.channelzEnabled) {
|
||||
this.listenerChildrenTracker.refChild(channelzRef);
|
||||
}
|
||||
return this.experimentalCreateConnectionInjectorWithChannelzRef(credentials, channelzRef);
|
||||
}
|
||||
|
||||
private closeServer(server: AnyHttp2Server, callback?: () => void) {
|
||||
this.trace(
|
||||
'Closing server with address ' + JSON.stringify(server.address())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user