0

We're using Thrift as our IDL/transport layer between a backend service, and a browser JS client, as well as, soon a NodeJS web server.

For scaling purposes, we have a requirement that we need to allow our infrastructure to read the response headers and HTTP response codes coming back from the Thrift server responses, to our applications using Thrift clients.

I can't, for the life of me, see how this is possible, when the underlying thrift JS library seems to only send along the resultant, thrift-typed data objects, built from the response body (success in the code below). The actual HTTP response object appears to just get swallowed up by garbage collection AFAICT:

https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/xhr_connection.js#L168-L186

client._reqs[dummy_seqid] = function(err, success) {
        transport_with_data.commitPosition();
        var clientCallback = client._reqs[header.rseqid];
        delete client._reqs[header.rseqid];
        if (clientCallback) {
          clientCallback(err, success);
        }
      };
      /*jshint +W083 */
      if (client['recv_' + header.fname]) {
        client['recv_' + header.fname](proto, header.mtype, dummy_seqid);
      } else {
        delete client._reqs[dummy_seqid];
        this.emit("error",
          new thrift.TApplicationException(
            thrift.TApplicationExceptionType.WRONG_METHOD_NAME,
            "Received a response to an unknown RPC function"));
      }
    }

Has anyone figured out a way to allow JS applications, utilizing Thrift clients, to introspect these HTTP response objects (namely, the headers and HTTP response status codes)?

RavenHursT
  • 2,336
  • 1
  • 25
  • 46

0 Answers0