{"id":26608920,"url":"https://github.com/sharpvik/pgmaster","last_synced_at":"2025-06-24T00:31:50.562Z","repository":{"id":278084089,"uuid":"934444308","full_name":"sharpvik/pgmaster","owner":"sharpvik","description":"Find your PostgreSQL master node with a single function call","archived":false,"fork":false,"pushed_at":"2025-02-17T22:28:28.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T00:57:55.604Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/sharpvik.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-17T21:01:52.000Z","updated_at":"2025-02-17T22:28:31.000Z","dependencies_parsed_at":"2025-02-17T23:23:58.017Z","dependency_job_id":null,"html_url":"https://github.com/sharpvik/pgmaster","commit_stats":null,"previous_names":["sharpvik/pgmaster"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sharpvik/pgmaster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Fpgmaster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Fpgmaster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Fpgmaster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Fpgmaster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharpvik","download_url":"https://codeload.github.com/sharpvik/pgmaster/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Fpgmaster/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261582644,"owners_count":23180633,"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":"2025-03-24T00:57:59.609Z","updated_at":"2025-06-24T00:31:50.542Z","avatar_url":"https://github.com/sharpvik.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `pgmaster`\n\nFind your PostgreSQL master node with a single function call.\n\n## Why?\n\nI had a PostgreSQL cluster with multiple nodes that would rotate the _master_\ntitle during regular maintenance and on master node failure. I also had a few\nCRON jobs that relied on getting the _read-write_ connection and they would fail\notherwise.\n\nI needed to make sure that they find the right _master_ on init. So I wrote this\nlibrary.\n\n## Usage\n\n```go\nfunc main() {\n    const timeout = 5 * time.Second\n\n    master, err := pgmaster.Find(connect, timeout, []string{\n        \"abc.db.example.net\",\n        \"def.db.example.net\",\n    })\n\n    // ... use master\n}\n\n// This is just an example of what it might look like.\n// Use your own connection settings in practice.\nfunc connect(host string) (*sql.DB, error) {\n    const port = 5432\n    return sql.Open(\"postgres\", connectionString(host, port))\n}\n```\n\n**NOTE:** the `timeout` is going to apply to each host separately and it only\nreally matters if some of the hosts become unavailable. For instance, with the\nexample timeout of 5 seconds, the longest it will take `pgmaster.Find` to check\n2 hosts is 5 seconds x 2 hosts = 10 seconds. Under normal circumstances, it is\nnot going to take that long, because all it takes to check for a master node is\nrunning a simple `SELECT`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpvik%2Fpgmaster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharpvik%2Fpgmaster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpvik%2Fpgmaster/lists"}