{"id":13482270,"url":"https://github.com/mafintosh/polo","last_synced_at":"2025-04-08T03:09:54.703Z","repository":{"id":2836126,"uuid":"3839206","full_name":"mafintosh/polo","owner":"mafintosh","description":"Polo is a zero configuration service discovery module written completely in Javascript.","archived":false,"fork":false,"pushed_at":"2015-03-30T00:07:09.000Z","size":344,"stargazers_count":247,"open_issues_count":8,"forks_count":20,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-04-14T04:08:30.285Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mafintosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-27T01:14:56.000Z","updated_at":"2023-11-26T18:55:20.000Z","dependencies_parsed_at":"2022-09-05T12:31:30.884Z","dependency_job_id":null,"html_url":"https://github.com/mafintosh/polo","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fpolo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fpolo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fpolo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fpolo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mafintosh","download_url":"https://codeload.github.com/mafintosh/polo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:00.454Z","updated_at":"2025-04-08T03:09:54.665Z","avatar_url":"https://github.com/mafintosh.png","language":"JavaScript","funding_links":[],"categories":["Modules","Packages","Protocols"],"sub_categories":["Network"],"readme":"# Polo\n\nPolo is a zero configuration (zeroconf, mdns or dns-sd) service discovery module written completely in Javascript. Unlike some other tools (https://github.com/agnat/node_mdns) it does not require the installation of Apple's Bonjour SDK.\nIt's available through npm:\n\n\tnpm install polo\n\n## What problem does it solve?\n\nPolo allows your servers/programs to discover eachother without having to talk to a central server and\nwithout the use of any static configuration as long as they are connected to the same local network.\n\n## Usage\n\nFirst create a polo instance:\n\n``` js\nvar polo = require('polo');\nvar apps = polo();\n```\n\nNow let's add a service to the app repository:\n\n``` js\napps.put({\n\tname:'hello-world', // required - the name of the service\n\thost:'example.com', // defaults to the network ip of the machine\n\tport: 8080          // we are listening on port 8080.\n});\n```\n\nIf you put multiple services with the same name Polo will load balance them for you by choosing a random service.\nNow spin up another node process and polo will automatically distribute information about this service:\n\n``` js\n// in another process\nvar polo = require('polo');\nvar apps = polo();\n\napps.once('up', function(name, service) {                   // up fires everytime some service joins\n\tconsole.log(apps.get(name));                        // should print out the joining service, e.g. hello-world\n});\n```\n\nAdditionally there is a `down` event which fires when a services leaves the repository - it's that easy!\n\n## Options\n\nPer default Polo will discover all services running on a network using UDP multicast.\nWhen developing it can often be very useful to disable this. To do so either provide `multicast: false` or set your `NODE_ENV=development` environment variable\n\n``` js\nvar apps = polo({\n\tmulticast: false     // disables network multicast,\n\tmonitor: true        // fork a monitor for faster failure detection,\n\theartbeat: 2*60*1000 // set the service heartbeat interval (defaults to 2min)\n});\n```\n\nor using development mode from the shell\n\n\t$ NODE_ENV=development node my-polo-app.js # also disables network multicast\n\n## Example\n\nLet's create an HTTP service. Try to run the program below on different machines in the same network:\n\n``` js\nvar http = require('http');\nvar polo = require('polo');\nvar apps = polo();\n\nvar server = http.createServer(function(req, res) {\n\tif (req.url !== '/') {\n\t\tres.writeHead(404);\n\t\tres.end();\n\t\treturn;\n\t}\n\n\tres.end('hello-http is available at http://'+apps.get('hello-http').address);\n});\n\nserver.listen(0, function() {\n\tvar port = server.address().port; // let's find out which port we binded to\n\n\tapps.put({\n\t\tname: 'hello-http',\n\t\tport: port\n\t});\n\n\tconsole.log('visit: http://localhost:'+port);\n});\n```\n\n## License\n\n**This software is licensed under \"MIT\"**\n\n\u003e Copyright (c) 2012 Mathias Buus Madsen \u003cmathiasbuus@gmail.com\u003e\n\u003e\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\u003e\n\u003e The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\u003e\n\u003e THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fpolo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmafintosh%2Fpolo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fpolo/lists"}