{"id":21831370,"url":"https://github.com/nodef/heroku-addonpool","last_synced_at":"2026-05-11T16:12:22.341Z","repository":{"id":57262896,"uuid":"107175109","full_name":"nodef/heroku-addonpool","owner":"nodef","description":"Manage Addon Pool of an App in Heroku.","archived":false,"fork":false,"pushed_at":"2022-01-19T18:35:36.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-26T10:17:57.383Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/heroku-addonpool","language":"JavaScript","has_issues":false,"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/nodef.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-10-16T19:43:51.000Z","updated_at":"2022-01-19T14:53:22.000Z","dependencies_parsed_at":"2022-09-01T04:32:02.320Z","dependency_job_id":null,"html_url":"https://github.com/nodef/heroku-addonpool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fheroku-addonpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fheroku-addonpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fheroku-addonpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fheroku-addonpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodef","download_url":"https://codeload.github.com/nodef/heroku-addonpool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244803653,"owners_count":20512961,"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-11-27T19:10:02.519Z","updated_at":"2026-05-11T16:12:22.335Z","avatar_url":"https://github.com/nodef.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Manages Addon Pool of an App in Heroku.\n\n```bash\n# NOTE:\n# The app with addons (pool app) must be different from the app\n# that uses the addons because heroku resets the pool app each\n# time a configuration variable is changed.\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n```bash\n# set heroku cli login in environment variables\nHEROKU_CLI_LOGIN=youremail@domain.com\nHEROKU_CLI_PASSWORD=yourpassword\n\n# also as of now you also need to purge cache before build\nheroku repo:purge_cache -a yourpoolapp\n```\n\n\u003cbr\u003e\n\n```javascript\nvar Pool = require('heroku-addonpool');\n// Pool(\u003cid\u003e, \u003capp\u003e, \u003copt\u003e)\n\n/* Assume \"ci-herokuaddonpool\" has 2 postgresql addons provisioned.\n * There are 3 consumers which need access to a postgresql database,\n * for a limited amount of time. Since we have only 2 available, we\n * create a pool to enable consumers to acquire (remove) and release\n * (add) database from the pool. If no database is available in the\n * pool, a consumer will have to wait (Promise) until the resource\n * is released by some other consumer.\n */\n\nvar pg = Pool('heroku-postgresql', 'ci-herokuaddonpool', {\n  'config': /(HEROKU_POSTGRESQL|DATABASE)\\S*URL/g,\n  'log': true\n});\n\npg.setup().then((ans) =\u003e {\n  var cona = 'consumer-a';\n  var conb = 'consumer-b';\n  var conc = 'consumer-c';\n  console.log(ans);      // available addons (Map)\n  console.log(ans.size); // number of addons\n  pg.remove(cona).then((ans) =\u003e {\n    console.log(ans.name);        // name of the addon\n    console.log(ans.attachments); // app to addon attachments\n    console.log(ans.installedAt); // provision date\n    console.log(ans.owningApp);   // owner app of this addon\n    console.log(ans.plan);        // addon service:plan\n    console.log(ans.price);       // addon price\n    console.log(ans.state);       // addon state\n    console.log(ans.value);       // addon access url\n    console.log(`${cona} has acquired ${ans.name}`);\n    console.log(`-\u003e connection string: ${ans.value}`);\n    // consumer-a uses database for 20s\n    setTimeout(() =\u003e {\n      console.log(`${cona} is releasing ${ans.name}`);\n      pg.add(cona);\n    }, 20000);\n  }).then(() =\u003e {\n    return pg.remove(conb);\n  }).then((ans) =\u003e {\n    console.log(`${conb} has acquired ${ans.name}`);\n    console.log(`-\u003e connection string: ${ans.value}`);\n    // consumer-b uses database for 10s\n    setTimeout(() =\u003e {\n      console.log(`${conb} is releasing ${ans.name}`);\n      pg.add(conb);\n    }, 10000);\n  }).then(() =\u003e {\n    return pg.remove(conc);\n  }).then((ans) =\u003e {\n    // consumer-c waits for 10s until consumer-b releases\n    console.log(`${conc} has acquired ${ans.name}`);\n    console.log(`-\u003e connection string: ${ans.value}`);\n    // consumer-c uses database for 10s\n    setTimeout(() =\u003e {\n      console.log(`${conc} is releasing ${ans.name}`);\n      pg.add(conc);\n    }, 10000);\n  });\n});\n```\n\n![](https://ga-beacon.deno.dev/G-RC63DPBH3P:SH3Eq-NoQ9mwgYeHWxu7cw/github.com/nodef/heroku-addonpool)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fheroku-addonpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodef%2Fheroku-addonpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fheroku-addonpool/lists"}