Posts

Showing posts with the label callback

nodejs http.request how to collect data

nodejs http.request how to collect data I am trying to invoke a rest API URL in one method and then use that response to form the next query to another URL, let's say git to query some information. I have seen numerous examples before posting this, in everyone people are simply printing the response to console or setting it to the server response. I have tried using async/await but it just makes the whole thing really slow. So, I am not so keen on using that approach. I am doing the callbacks but I am not able to collect data to actually loop over it. Here is my code snippet:- function initialize(path) { // Setting URL and headers for request var options = { url: '', headers: { 'Accept': '*/*', 'User-Agent' : 'something something', 'Authorization': 'Basic ' + new Buffer(process.env.username + ':' + process.env.password).toString('base64') }, ...

Protobuf RPC callbacks

Protobuf RPC callbacks Is there any way to do the invoke call from server to the client with Protobuf RPC(while custom call from client to the server, not directly)? I'm meaning, for example, describe service method in *.proto file with callback param? Im using gRPC library. 1 Answer 1 The general way to do server->client messages in gRPC is through "streaming". That is, the client makes a call to the server, and then the server can "stream" back a series of messages to the client before eventually completing the call. See: http://www.grpc.io/docs/guides/concepts.html#server-streaming-rpc Of course, "streaming" is a pretty different pattern from a traditional "callback", but you can often solve the same problems with it. Note that Cap'n Proto RPC -- an alternative to Protobuf and gRPC -- fully supports calls in both directions by virtue of supportin...