Service callout from node.js app

Not applicable

Is there any way to call another service from node.js app without extra network hops?

Example:

I've got 2 service – service A returns item by id, service B receives list of ids and should respond with list of items.

How can I do so that service B will call service A multiple times without using A's external url?

Solved Solved
0 4 299
1 ACCEPTED SOLUTION

It depends on what you call a _service_, and where they live. If both services are in the same node.js application, you could wrap the code behind the service in a module that could be called directly instead of making an HTTP request (which would use a network hop). If the services are not in the same location, I don't know you could save a network hope so I'll assume this isn't the case.

View solution in original post

4 REPLIES 4

It depends on what you call a _service_, and where they live. If both services are in the same node.js application, you could wrap the code behind the service in a module that could be called directly instead of making an HTTP request (which would use a network hop). If the services are not in the same location, I don't know you could save a network hope so I'll assume this isn't the case.

I'm talking about 2nd case, when service is separate node.js-based proxy app on apigee. E.g. when I run 2 simple express apps on Google Cloud VMs or app instances (in case of GAE use), I have 2 IPs for each app environment (internal and external one), so I can expose APIs to end-users using external IP and also call the same API from 2nd app using internal IP.

Separate node.js applications deployed on Edge cannot communicate directly with each other and will require a network hop for service A to communicate with service B.

yes! And that hop will go through the API Proxy endpoint for service B.