{"id":15601210,"url":"https://github.com/hacknlove/meteor-primary","last_synced_at":"2026-06-09T01:05:47.348Z","repository":{"id":77996050,"uuid":"70043830","full_name":"hacknlove/meteor-primary","owner":"hacknlove","description":"Primary / Secondary(s) cluster for Meteor","archived":false,"fork":false,"pushed_at":"2017-03-21T13:50:28.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-26T07:34:20.246Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacknlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-05T08:49:58.000Z","updated_at":"2016-10-05T08:53:08.000Z","dependencies_parsed_at":"2023-03-12T03:10:06.904Z","dependency_job_id":null,"html_url":"https://github.com/hacknlove/meteor-primary","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.33333333333333337","last_synced_commit":"a3036260bc979b516dbc10d531b43e8467b96386"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hacknlove/meteor-primary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmeteor-primary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmeteor-primary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmeteor-primary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmeteor-primary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacknlove","download_url":"https://codeload.github.com/hacknlove/meteor-primary/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmeteor-primary/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285354068,"owners_count":27157385,"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","status":"online","status_checked_at":"2025-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-03T02:19:52.161Z","updated_at":"2025-11-20T01:02:48.049Z","avatar_url":"https://github.com/hacknlove.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Primary / Secondary(s) cluster for Meteor\n\n### Important: All the server instances must share the mongo database.**\n\njust add this package `meter add hacknlove:primary` and you'll get:\n\n### `Primary.serverId`\nJust a runtime uuid for the server set at startup.\nNext startup, it will have a diferent value.\n\n### `Primary.isPrimary` and `Primary.isSecondary`\nDuring the startup they could be both false, until someone is choosen Primary, so use them only at runtime, not at startup time.\n\n\n### `Primary.becomePrimary(callback)` and `Primary.becomeSecondary(callback)`\nYou can call those as many times as you want, attaching a new callback each time.\n\nThey returns a function that if called, dettaches callback.\n\nWhen a new Primary is choosen:\n* The Secondary that becomes Primary, calls becomePrimary callbacks.\n* The Primary that becomess Secondary, calls becomeSecondary callbacks.\n* The Secondaries that remains Secondaries, calls nothing.\n\nThe callbacks receive as parameter a callable that if called, dettaches the callback.\n\n### How it works:\n\nEvery server insert himself in the HacknlovePrimary collection with a timestamp\n\nThe one with the oldest Timestamp becomes Primary.\n\nEvery hearthbeat, the servers update their timestamp.\n\nThe Primary set his timestamp in the future (Now + hearthbeat - 1), in order to remain Primary.\n\nSo it does not change every time a new server is added to the cluster, and we do not want the primary to change randomly in each hearthbeat.\n\nThe timestamp olders than `hearthbeat * 4` are cleaned.\n\n---\n# Disclaimer:\n\nThis package is still beta, and it is not ready for production, nevertheless I am using it in production, but at my own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fmeteor-primary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacknlove%2Fmeteor-primary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fmeteor-primary/lists"}