apcera/gnatsd — pull request #52 by chendo (2014-09-23 07:37:39+00:00)
Title: Dynamic cluster route management

We're using gnatsd inside Mesos/Marathon, so routes to other nodes can change often. We initially experimented with generating config files with routes from Marathon, however the config files would only have routes for the other gnatsd nodes at that point in time which was not ideal.

I've implemented a `/routez` endpoint (mostly copied from `connz.go`) that allows listing, adding and removing routes.

The API is as follows:
```
curl -X GET localhost:9222/routez # Returns list of routes
curl -X PUT localhost:9222/routez -d nats://: # Add a route. I used PUT because gnatsd automatically handles duplicate routes
curl -X DELETE localhost:9222/routez -d nats://: # Removes a route if it exists.
```

I used a simple text body because the route addition/removal didn't need to be that complex, and handling JSON requests would be slightly more complicated and unnecessary.

It would be handy to find out how many times a particular route has disconnected and reconnected, but wasn't a critical feature for us just yet.