diff options
author | Shintaro Kojima <goodies@codeout.net> | 2015-11-15 21:51:51 +0900 |
---|---|---|
committer | Shintaro Kojima <goodies@codeout.net> | 2015-11-15 21:51:51 +0900 |
commit | dbd83f729fe9f616ba5784fa5e1e3438654e3d93 (patch) | |
tree | 5a70b18545792d28e19857d8483a1c9ebd1cb512 /tools/grpc | |
parent | f78e1a91dd6f28e00e395bd44873942b7fc11132 (diff) |
Add an example of Node.js
Diffstat (limited to 'tools/grpc')
-rw-r--r-- | tools/grpc/nodejs/get_neighbors.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/grpc/nodejs/get_neighbors.js b/tools/grpc/nodejs/get_neighbors.js new file mode 100644 index 00000000..c1ec763b --- /dev/null +++ b/tools/grpc/nodejs/get_neighbors.js @@ -0,0 +1,24 @@ +var grpc = require('grpc'); +var api = grpc.load('gobgp.proto').gobgpapi; +var stub = new api.GobgpApi('localhost:8080', grpc.Credentials.createInsecure()); + +var call = stub.getNeighbors({}); +call.on('data', function(neighbor) { + console.log('BGP neighbor is', neighbor.conf.remote_ip, + ', remote AS', neighbor.conf.remote_as); + console.log("\tBGP version 4, remote route ID", neighbor.conf.id); + console.log("\tBGP state =", neighbor.info.bgp_state, + ', up for', neighbor.info.uptime); + console.log("\tBGP OutQ =", neighbor.info.out_q, + ', Flops =', neighbor.info.flops); + console.log("\tHold time is", neighbor.info.negotiated_holdtime, + ', keepalive interval is', neighbor.info.keepalive_interval, 'seconds'); + console.log("\tConfigured hold time is", neighbor.conf.holdtime); +}); +call.on('end', function() { + // do something when the server has finished sending +}); +call.on('status', function(status) { + // do something with the status +}); + |