Skip to content

GRPC how to reuse client connection? #359

@loginakhil

Description

@loginakhil
 // 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)
})

If ServiceA and ServiceB are served by same server, is there any way by which i can reuse the client object ?

Can i do something like this :

let commonClient = new grpc.Client(common_url, grpc.credentials.createInsecure());

commonClient.ServiceA.functionOne();

commonClient.ServiceB.functionTwo();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions