GRPC如何重用客户端连接?

时间:2018-05-21 17:06:14

标签: node.js grpc

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER <Schema_Name, sysname, Schema_Name>.<Trigger_Name, sysname, Trigger_Name> 
   ON  <Schema_Name, sysname, Schema_Name>.<Table_Name, sysname, Table_Name> 
   AFTER <Data_Modification_Statements, , INSERT,DELETE,UPDATE>
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for trigger here

END
GO

如果 // ServiceA - proto const proto = grpc.load({ root: protoDir, file: 'serviceA.proto' }); // ServiceB - proto const proto = grpc.load({ root: protoDir, file: 'serviceB.proto' }); let clientA = new ddl_proto.com.mypackage.serviceA(common_url, grpc.credentials.createInsecure()); clientA.functionOne({ options: JSON.stringify(user_options) }, (error, response) => { console.log(response) }) let clientB = new ddl_proto.com.mypackage.serviceB(common_url, grpc.credentials.createInsecure()); clientB.functionTwo({ options: JSON.stringify(user_options) }, (error, response) => { console.log(response) }) ServiceA由同一台服务器提供服务,我有什么办法可以重用客户端对象吗?

我可以这样做:

ServiceB

1 个答案:

答案 0 :(得分:0)

Answer from grpc developers

目前,您无法为两个不同的服务显式连接到客户端的单个连接。但是,如果您使用相同的URL,凭据和选项(如果有)创建两个客户端,则它们最终应使用相同的基础连接。

感谢Michael Lumish