{"id":16600992,"url":"https://github.com/koalazak/redis-registry","last_synced_at":"2025-06-22T23:08:10.276Z","repository":{"id":57349802,"uuid":"103675492","full_name":"koalazak/redis-registry","owner":"koalazak","description":"Service registry and discovery for Node.js on top of Redis","archived":false,"fork":false,"pushed_at":"2021-10-21T11:17:55.000Z","size":17,"stargazers_count":29,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T22:29:33.212Z","etag":null,"topics":["discovery","microservice","microservices","redis","registry","service"],"latest_commit_sha":null,"homepage":null,"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/koalazak.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":"2017-09-15T15:56:51.000Z","updated_at":"2025-05-06T15:11:13.000Z","dependencies_parsed_at":"2022-09-15T15:30:42.024Z","dependency_job_id":null,"html_url":"https://github.com/koalazak/redis-registry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/koalazak/redis-registry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koalazak%2Fredis-registry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koalazak%2Fredis-registry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koalazak%2Fredis-registry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koalazak%2Fredis-registry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koalazak","download_url":"https://codeload.github.com/koalazak/redis-registry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koalazak%2Fredis-registry/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261380910,"owners_count":23149966,"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":["discovery","microservice","microservices","redis","registry","service"],"created_at":"2024-10-12T00:16:25.741Z","updated_at":"2025-06-22T23:08:05.262Z","avatar_url":"https://github.com/koalazak.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# redis-registry\n\n[![Build Status](https://travis-ci.org/koalazak/redis-registry.svg?branch=master)](https://travis-ci.org/koalazak/redis-registry)\n[![npm version](https://badge.fury.io/js/redis-registry.svg)](http://badge.fury.io/js/redis-registry)\n\nService registry and discovery for distributed systems on top of [redis](https://github.com/NodeRedis/node_redis) and node.js\n\n## Install\n\n```bash\nnpm install redis-registry\n```\n\n## Usage\n\nComputer 1\n``` js\nconst registry = require('redis-registry');\n\nconst redisConfig = {\n  host: '192.168.1.50',\n  port: 6379\n}\nconst services = registry(redisConfig);\n\n// Join the registry\nservices.join('my-service-name', {port:8080});\n```\n\nComputer 2\n``` js\nconst registry = require('redis-registry');\n\nconst redisConfig = {\n  host: '192.168.1.50',\n  port: 6379\n}\nconst services = registry(redisConfig);\n\n// Do a lookup\nservices.lookup('my-service-name', function(err, service) {\n  console.log('Found the following service:');\n  console.log(service);\n});\n```\n\nRunning the above [example](https://github.com/koalazak/redis-registry/blob/master/example.js) will produce the following output\n\n```\nFound the following service:\n{\n  name: 'my-service-name',\n  port: 8080,\n  hostname: '192.168.1.10',\n  host: '192.168.1.10:8080',\n  url: 'http://192.168.1.10:8080'\n}\n```\n\n**Note**: If no hostname is passed to the `join` function, it will pickup the main interface IP as the hostname. If you need to use the IP of a non-primary interface, set the environment variable `REGISTRY_INTERFACE` to the name of the device of your choice (`eth1`, `en1`, etc)\n\n## Full api\n\n* `services = registry(redisConfig)` Create a new registry client\n* `services.join(name, service, [cb])` Join the registry with a new service\n* `services.leave([name], [cb])` Leave the registry.\n* `services.lookup(name, cb)` Lookup a single service\n* `services.list([name], cb)` List all services as an array. Omit the name to list all services\n\n## Services\n\nServices are just JSON documents. `redis-registry` will add a default `hostname` and a couple of other properties.\nAn example of a service document could be:\n\n``` js\n{\n  name: 'my-service',\n  port: 8080,\n  hostname: '192.168.1.10',       // added by redis-registry\n  host: '192.168.1.10:8080',      // added by redis-registry\n  url: 'http://192.168.1.10:8080' // added by redis-registry\n}\n```\n\nThese documents are saved in [redis](https://redis.io/) with a TTL of 10s.\nEvery 5s `redis-registry` will send an update for each service to the registry which resets the expiration counter keeping the service record.\nIf possible you should call `services.leave()` before exiting your service process. Otherwise your service will be garbage collected after (at most) 10s.\nIf your process goes down, it will automatically leave the registry (due to the TTL) and will not be discovered from other process.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoalazak%2Fredis-registry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoalazak%2Fredis-registry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoalazak%2Fredis-registry/lists"}