The client for Harbourmaster simplifies communication to the harbourmaster client.
By simplifying service discovery, a network of microservices can communicate to one-another without hard-coded configuration.
var argv = require('minimist')(process.argv.splice(2)),
hm_host = argv.host || "localhost",
hm_port = argv.port || 8080;
var hm = require('harbourmaster-client')(hm_host, hm_port),
net = require('net');
var server = net.createServer(function(socket) {
console.log("Connection Established.");
socket.on('data', function(data) {
console.log("Received:", data.toString());
socket.write("You wrote: "+ data.toString());
});
}).listen(function() {
console.log("Listening on: "+ this.address().port);
hm.register('echo', this.address(), function(err) {
if (err) throw err;
});
});
var argv = require('minimist')(process.argv.splice(2)),
hm_host = argv.host || "localhost",
hm_port = argv.port || 8080;
var hm = require('harbourmaster-client')(hm_host, hm_port),
Socket = require('net').Socket;
hm.get('echo', function(err, address) {
if (err) throw err;
var socket = new Socket();
socket.connect(address.port, address.address);
socket.write("Hello World");
socket.on("data", function(data) {
console.log("Response: " + data.toString());
socket.end();
});
});