Skip to content

Instantly share code, notes, and snippets.

@terrancesnyder
Created October 23, 2012 02:04
Show Gist options
  • Save terrancesnyder/3936255 to your computer and use it in GitHub Desktop.
Save terrancesnyder/3936255 to your computer and use it in GitHub Desktop.
Interesting concept for self-assembling nodes
infrastructure
.discover('solr')
.enter(function(instance) { // when a new instance has announced itself or come online again
// instance.port
// instance.core
// instance.ip
// instance.ttl
})
.exit(function(instance) { // when an instance has left
// when an instance has left we can now unregister it
});
// announce yourself to the infrastructure so
// that others can tie into you
infrastructure.announce('solr', {
port: 8080, // port we are running the service on
core: '0002-01', // unique core name
ip: '192.168.0.1', // the exposed address of the solr instance
ttl: 1000 // the time-to-live (after this we should check if we exist)
});
// announce will continually announce at the TTL time, listen is responsible for detecting an outage
// and triggering the enter and exit functon
// announce we are leaving
infrastructure.leave('solr', {
port: 8080, // port we are running the service on
core: '0002-01', // unique core name
ip: '192.168.0.1', // the exposed address of the solr instance
ttl: 1000 // the time-to-live (after this we should check if we exist)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment