{"id":15926641,"url":"https://github.com/nflaig/loopback4-cosmosdb-retry","last_synced_at":"2025-03-24T14:32:51.364Z","repository":{"id":38418628,"uuid":"293071714","full_name":"nflaig/loopback4-cosmosdb-retry","owner":"nflaig","description":"LoopBack 4 Azure Cosmos DB data source retry mixin","archived":false,"fork":false,"pushed_at":"2024-06-16T13:51:40.000Z","size":670,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T10:11:52.315Z","etag":null,"topics":["cosmosdb","datasource","loopback-4","mixin","retry"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/nflaig.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-09-05T12:30:10.000Z","updated_at":"2022-01-13T13:49:48.000Z","dependencies_parsed_at":"2024-10-06T22:41:45.040Z","dependency_job_id":"6118e3cd-893e-48f9-8089-1b7c2ff4972a","html_url":"https://github.com/nflaig/loopback4-cosmosdb-retry","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":"0.22857142857142854","last_synced_commit":"0f6a0ff2e639d00a8c1af9d21d753ceb7eaeaf91"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nflaig%2Floopback4-cosmosdb-retry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nflaig%2Floopback4-cosmosdb-retry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nflaig%2Floopback4-cosmosdb-retry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nflaig%2Floopback4-cosmosdb-retry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nflaig","download_url":"https://codeload.github.com/nflaig/loopback4-cosmosdb-retry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245289802,"owners_count":20591136,"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":["cosmosdb","datasource","loopback-4","mixin","retry"],"created_at":"2024-10-06T22:41:32.573Z","updated_at":"2025-03-24T14:32:50.926Z","avatar_url":"https://github.com/nflaig.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- omit in toc --\u003e\n# loopback4-cosmosdb-retry\n\n[![Actions Status][build-badge]][actions]\n[![Coverage Status][coveralls-badge]][coveralls]\n\n[![Latest version][npm-version-badge]][npm-package]\n[![License][license-badge]][license]\n[![Downloads][npm-downloads-badge]][npm-package]\n[![Total Downloads][npm-total-downloads-badge]][npm-package]\n\nLoopBack 4 data source mixin to handle database operation retries in case of Azure Cosmos DB request\nlimit errors caused by exceeding the available [Request Units][request-units].\n\n\u003c!-- omit in toc --\u003e\n## Contents\n\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Configuration](#configuration)\n- [Debug](#debug)\n- [Related resources](#related-resources)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Prerequisites\n\nSome dependencies need to be installed as peer dependencies\n\n```shell\n@loopback/repository\n```\n\n## Installation\n\n```shell\nnpm install loopback4-cosmosdb-retry\n```\n\n## Usage\n\nThe mixin just needs to added to the data source\n\n```ts\nimport { juggler } from \"@loopback/repository\";\nimport { RetryMixin } from \"loopback4-cosmosdb-retry\";\n\nclass CosmosdbDataSource extends RetryMixin(juggler.DataSource) {}\n```\n\n## Configuration\n\nThe [default values][default-values] can be directly overwritten in the data source class\n\n```ts\nclass CosmosdbDataSource extends RetryMixin(juggler.DataSource) {\n    constructor(args) {\n        super(args);\n\n        // do 19 retries after the first request (default: 9)\n        this.maxRetries = 19;\n\n        // default delay if no suggested delay is in error response (default: 1000)\n        this.retryAfterInMs = 2000;\n\n        // additional delay to add to the suggested delay in error response (default: 0)\n        this.retryAfterPaddingInMs = 200;\n\n        // always use fixed retry interval based on retryAfterInMs (default: false)\n        this.useFixedRetryInterval = false;\n    }\n}\n```\n\nor by using environment variables\n\n\u003e .env\n\n```sh\nMAX_RETRIES=19\nRETRY_AFTER_IN_MS=2000\nRETRY_AFTER_PADDING_IN_MS=200\nUSE_FIXED_RETRY_INTERVAL=false\n```\n\n**Note:** The values you are setting directly in your code will have precedence over the environment variables.\nIf you want to be able to set values in your code while also having the options to overwrite with environment variables\nyou need to manually handle this.\n\n```ts\n\n// ...\n\n    constructor(args) {\n        super(args);\n\n        this.maxRetries =  Number(process.env.MAX_RETRIES) ?? 19;\n    }\n\n// ...\n\n```\n\n## Debug\n\nTo enable debug logs set the `DEBUG` environment variable to `loopback:cosmosdb-retry`, see\n[Setting debug strings][lb4-debug-strings] for further details.\n\n## Related resources\n\n- [LoopBack 4 Mixins][lb4-mixins]\n- [Request Units in Azure Cosmos DB][request-units]\n\n## Contributing\n\n[![contributions welcome][contributions-welcome-badge]][issues]\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.\n\n[actions]: https://github.com/nflaig/loopback4-cosmosdb-retry/actions\n[license]: https://github.com/nflaig/loopback4-cosmosdb-retry/blob/master/LICENSE\n[issues]: https://github.com/nflaig/loopback4-cosmosdb-retry/issues\n[coveralls]: https://coveralls.io/github/nflaig/loopback4-cosmosdb-retry?branch=refs/heads/master\n[npm-package]: https://www.npmjs.com/package/loopback4-cosmosdb-retry\n\n[build-badge]: https://github.com/nflaig/loopback4-cosmosdb-retry/workflows/build/badge.svg\n[coveralls-badge]: https://coveralls.io/repos/github/nflaig/loopback4-cosmosdb-retry/badge.svg?branch=refs/heads/master\n[npm-version-badge]: https://img.shields.io/npm/v/loopback4-cosmosdb-retry.svg?style=flat-square\n[npm-downloads-badge]: https://img.shields.io/npm/dw/loopback4-cosmosdb-retry.svg?label=Downloads\u0026style=flat-square\u0026color=blue\n[npm-total-downloads-badge]: https://img.shields.io/npm/dt/loopback4-cosmosdb-retry.svg?label=Total%20Downloads\u0026style=flat-square\u0026color=blue\n[license-badge]: https://img.shields.io/github/license/nflaig/loopback4-cosmosdb-retry.svg?color=blue\u0026label=License\u0026style=flat-square\n[contributions-welcome-badge]: https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat\n\n[request-units]: http://aka.ms/cosmosdb-error-429\n[lb4-mixins]: https://loopback.io/doc/en/lb4/Mixin.html\n[lb4-debug-strings]: https://loopback.io/doc/en/lb4/Setting-debug-strings.html\n[default-values]: https://github.com/nflaig/loopback4-cosmosdb-retry/blob/master/src/retry.ts#L4\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnflaig%2Floopback4-cosmosdb-retry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnflaig%2Floopback4-cosmosdb-retry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnflaig%2Floopback4-cosmosdb-retry/lists"}