discover.register(contact) API forces breaking encapsulation
Closed this issue · 3 comments
tristanls commented
Requiring contact.transport
when registering a contact
(as shown below) violates encapsulation when Discover is used by another library. The below excerpt from tristanls/tart-ansible/index.js#L59 illustrates the problem:
var registerDomain = function registerDomain(domainName, receptionist) {
var data = {};
Object.keys(transports).forEach(function (scheme) {
data[scheme] = transports[scheme].data;
});
var contact = {
id: domainName,
data: data,
transport: {
host: discover.transport.host, // <- reaching all up in discover's pockets
port: discover.transport.port
}
};
domains[domainName] = receptionist;
discover.register(contact);
};
tristanls commented
In order to fix this, we need contact.transport
to be optional (or preferably even disallowed) when calling discover.register(contact)
.
tristanls commented
Implementation of tcpTransport.setTransportInfo(contact) now enables Discover to add correct transport
data to contact's upon registration.