mirror of https://github.com/grpc/grpc-node.git
Merge pull request #1961 from murgatroid99/grpc-js_channelz_disable_fix
grpc-js: Fix handling of grpc.enable_channelz option
This commit is contained in:
commit
cb29b6af0f
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/grpc-js",
|
"name": "@grpc/grpc-js",
|
||||||
"version": "1.4.2",
|
"version": "1.4.3",
|
||||||
"description": "gRPC Library for Node - pure JS implementation",
|
"description": "gRPC Library for Node - pure JS implementation",
|
||||||
"homepage": "https://grpc.io/",
|
"homepage": "https://grpc.io/",
|
||||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||||
|
|
|
@ -832,6 +832,7 @@ export class Subchannel {
|
||||||
headersString
|
headersString
|
||||||
);
|
);
|
||||||
const streamSession = this.session;
|
const streamSession = this.session;
|
||||||
|
let statsTracker: SubchannelCallStatsTracker;
|
||||||
if (this.channelzEnabled) {
|
if (this.channelzEnabled) {
|
||||||
this.callTracker.addCallStarted();
|
this.callTracker.addCallStarted();
|
||||||
callStream.addStatusWatcher(status => {
|
callStream.addStatusWatcher(status => {
|
||||||
|
@ -851,7 +852,7 @@ export class Subchannel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
callStream.attachHttp2Stream(http2Stream, this, extraFilters, {
|
statsTracker = {
|
||||||
addMessageSent: () => {
|
addMessageSent: () => {
|
||||||
this.messagesSent += 1;
|
this.messagesSent += 1;
|
||||||
this.lastMessageSentTimestamp = new Date();
|
this.lastMessageSentTimestamp = new Date();
|
||||||
|
@ -859,8 +860,14 @@ export class Subchannel {
|
||||||
addMessageReceived: () => {
|
addMessageReceived: () => {
|
||||||
this.messagesReceived += 1;
|
this.messagesReceived += 1;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
} else {
|
||||||
|
statsTracker = {
|
||||||
|
addMessageSent: () => {},
|
||||||
|
addMessageReceived: () => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
callStream.attachHttp2Stream(http2Stream, this, extraFilters, statsTracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -286,4 +286,36 @@ describe('Channelz', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Disabling channelz', () => {
|
||||||
|
let testServer: grpc.Server;
|
||||||
|
let testClient: ServiceClient;
|
||||||
|
beforeEach((done) => {
|
||||||
|
testServer = new grpc.Server({'grpc.enable_channelz': 0});
|
||||||
|
testServer.addService(TestServiceClient.service, testServiceImpl);
|
||||||
|
testServer.bindAsync('localhost:0', grpc.ServerCredentials.createInsecure(), (error, port) => {
|
||||||
|
if (error) {
|
||||||
|
done(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
testServer.start();
|
||||||
|
testClient = new TestServiceClient(`localhost:${port}`, grpc.credentials.createInsecure(), {'grpc.enable_channelz': 0});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
testClient.close();
|
||||||
|
testServer.forceShutdown();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should still work', (done) => {
|
||||||
|
const deadline = new Date();
|
||||||
|
deadline.setSeconds(deadline.getSeconds() + 1);
|
||||||
|
testClient.unary({}, {deadline}, (error: grpc.ServiceError, value: unknown) => {
|
||||||
|
assert.ifError(error);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue