artnikpro
artnikpro

Reputation: 5869

Connecting to Foxx app as TCP bridge?

I'm currently setting up my Foxx app as a GraphQL API endpoint and I would need to connect to it from the browser and the Node backend. There is an arango.client npm package that I'm thinking to install for my backend but it seems that it only supports HTTP. Wouldn't it be better to create a TCP connection bridge once (in Node) and communicate with it with lower latency and less overhead? I know that ArangoDB supports for TCP but why it is not implemented in arango.client?

Upvotes: 1

Views: 130

Answers (1)

dothebart
dothebart

Reputation: 6067

Currently ArangoDB only implements HTTP as transportation endpoint.

Source for irretation may be that specifying the arangosh commandline parameter for the server connection looks like this:

--server.endpoint tcp://127.0.0.1:8529

But the protocol spoken there is HTTP.

One step to bypass the TCP stack could be to use unix domain sockets for the HTTP communication. You can use Raw routes to communicate with your Foxx service:

var db = require('arangojs')();
var myFoxxService = db.route('my-foxx-service');
myFoxxService.post('users', {
    username: 'admin',
    password: 'hunter2'
})
.then(response => {
    // response.body is the result of
    // POST /_db/_system/my-foxx-service/users
    // with JSON request body '{"username": "admin", "password": "hunter2"}'
});

ArangoDB 3.0 will bring velocypack and later on raw tcp protocoll to sideline HTTP. Foxx support is also planned for this.

While arangojs is currently a pure js implementation, we plan to offer a native backend under a similar API in the future. So if you want to benefit of that, you should go with ArangoJS now.

Upvotes: 1

Related Questions