{"_id":"@drizzle-http/opossum-circuit-breaker","_rev":"2-11565e0e997009b5a1492f639a6e23e3","name":"@drizzle-http/opossum-circuit-breaker","dist-tags":{"latest":"3.1.0"},"versions":{"3.0.0":{"name":"@drizzle-http/opossum-circuit-breaker","version":"3.0.0","description":"Opossum implementation for Drizzle-HTTP","dependencies":{"@drizzle-http/core":"^3.0.0","opossum":"^6.2.1"},"repository":{"type":"git","url":"git+https://github.com/vitorsalgado/drizzle-http.git","directory":"packages/drizzle-opossum-circuit-breaker"},"homepage":"https://github.com/vitorsalgado/drizzle-http/tree/main/packages/drizzle-opossum-circuit-breaker","keywords":["drizzle-http","circuit-breaker","circuit breaker","circuitbreaker","resilience","fail-fast","http","api","rest","decorators"],"author":{"name":"Vitor Hugo Salgado","url":"https://github.com/vitorsalgado"},"license":"MIT","engines":{"node":">=16"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./package.json":"./package.json"},"bugs":{"url":"https://github.com/vitorsalgado/drizzle-http/issues"},"_id":"@drizzle-http/opossum-circuit-breaker@3.0.0","_integrity":"sha512-sNOFhWCQu0+/rzU9KMY7FUgJkBaB/lT0hS44zQGumhFbgLbdRW4I981knrWwM5PQdsSwEnULD/YO2leNq9livA==","_resolved":"/home/runner/work/drizzle-http/drizzle-http/packages/drizzle-opossum-circuit-breaker/package.tgz","_from":"file:package.tgz","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-sNOFhWCQu0+/rzU9KMY7FUgJkBaB/lT0hS44zQGumhFbgLbdRW4I981knrWwM5PQdsSwEnULD/YO2leNq9livA==","shasum":"f94836d40ce6d19b0057dde9aef9153f075c34d8","tarball":"https://registry.npmjs.org/@drizzle-http/opossum-circuit-breaker/-/opossum-circuit-breaker-3.0.0.tgz","fileCount":41,"unpackedSize":29803,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh0jt1CRA9TVsSAnZWagAAJxUP/0HrCN1hU865BJirJWHl\n40bMEV/+9jEL1U53sh40VUTsxzu+wNc/3LmzYAa+Ne/arIYFUJYkVUBsn7oz\nou7Yz1gtN+SRieu4ZWTm78zNzGH8RX6hztfbYvf6mBo75KEWpS3EfKLflcWi\nGk6Z109eGulGFPYRuiAO4zRrwp0C0Y9gvSngYjWObT6IKHah5R4/rGAQH0ws\nUGhEwSadQXJU8alV1nBGTP1Zlmhsqew0XwdIK0SaO5htVpn82cTjdjFRFkxo\nLza5Ox11kXbrzRBj8LZnIF9fEQYsQ8AWOw5N/i5kowa0bbLoCeVFjvmpQZc4\nEo96YGt67XKzDi/pc8vPa8X1cP+UEsADMWQf+3DQHWFhW2EjENTJoXwZUWD+\nL3REJYYsd4OsF8ICNr7J9QfwBj4FaQOzNvuJ1TMvhqhnkytiLTZ/BIyR3mzn\nC4kRx0uKn2CGoNkVwjs9ZJZJp5IU9oOTj66GkwzG++3NNODNY8ch7F+ikpoI\nrdXmfci7d2XjsPXjvkMYFvQwzerzRF9FkBSi/kAUbGsQkFvoEALIN6LGXXGI\nzehTezuKQBV8PqnVi3xUz4oS6SMe6mHnGr6QsbaBr3tq+GWFEP/GKj/OqD+R\nh1IGIqDvl09nDybJnK6rojzc3cZcaxzPhY1H/qVtawvCeqFnmnKHOmzF4mYI\nAg/1\r\n=Ok5H\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDh/5TMnFWvhO1jQF4d4ckEeuzuvQMoOeLpxDemEJlItQIgehQ8CYWwqqu0XNMSoFyZqwn6MLa6dByAQNh90XYeh5o="}]},"_npmUser":{"name":"vitor.salgado","email":"vsalgadopb@gmail.com"},"directories":{},"maintainers":[{"name":"vitor.salgado","email":"vsalgadopb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/opossum-circuit-breaker_3.0.0_1641167733229_0.1230931045484569"},"_hasShrinkwrap":false},"3.1.0":{"name":"@drizzle-http/opossum-circuit-breaker","version":"3.1.0","description":"Opossum implementation for Drizzle-HTTP","dependencies":{"@drizzle-http/core":"^3.1.0","opossum":"^6.2.1"},"repository":{"type":"git","url":"git+https://github.com/vitorsalgado/drizzle-http.git","directory":"packages/drizzle-opossum-circuit-breaker"},"homepage":"https://github.com/vitorsalgado/drizzle-http/tree/main/packages/drizzle-opossum-circuit-breaker","keywords":["drizzle-http","circuit-breaker","circuit breaker","circuitbreaker","resilience","fail-fast","http","api","rest","decorators"],"author":{"name":"Vitor Hugo Salgado","url":"https://github.com/vitorsalgado"},"license":"MIT","engines":{"node":">=16"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./package.json":"./package.json"},"bugs":{"url":"https://github.com/vitorsalgado/drizzle-http/issues"},"gitHead":"c4d9812ec060666ffcc4712b143b5317bdb52791","_id":"@drizzle-http/opossum-circuit-breaker@3.1.0","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-BF4VCRJsCDGAAhZbtK1RFNajD5iSQbNviLnmoGniLHRIc3mKrVp9bfJESmsi54o8Rh338hSLkzv7IS4ZF4itoQ==","shasum":"019813edf08fc7aa28507c5c9d992a9fefafe740","tarball":"https://registry.npmjs.org/@drizzle-http/opossum-circuit-breaker/-/opossum-circuit-breaker-3.1.0.tgz","fileCount":31,"unpackedSize":22600,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh0pgxCRA9TVsSAnZWagAAb7sQAIYgOlqYwb88z6YYn5YP\ncUchq1OkFYG3soox3WciAvaFnW3Nmns21LEE3/f2XBid20ns+cer35etZBKR\nQr/Xt5zxZKTMiovJhIcxgiaacMb75xzaoRSgGNyjPPEJJnLjJHAjCXek21jp\n3JE9up1/3xTr8m0HIDlzB+V0WUTy96zbtCJBTM7q2bkHK1Gh/+DZY0HNCxmU\nSyGk+t71egHB1/ntfRJ6UeswgkKYgBQrbYV662+SBliCfRobkalBf2Kpt4/g\nxxp+/HgBUkvw06xnHVc7JO4hBukkxbbce097m+VeNikn7ZdK4k0gBEkIewV3\nqb4V82vMfJhHRn/BLlwJ1BlNOhSjcmyg56grCnPJuN4SfgUT68w0r7HP6UCw\nGJVTbHNtvdtDTiqNhzW7R0IEF27O6ggqwrXicee6yUNx532xY8XImFj1c+MG\nVKYH8x30kj5xkd9ZGQfclR/FLO6LvdVDrfbMRANrSnqecLWmgSeZGmjqNyZB\nBMDWIhWae6N4/fUvAvXMgNxkteZVTaWELIL/mMttu7U+bsxUc/+cj5CDgOQ0\naAbU2XcbUPTjLtzmOx9UedmqnKYfmzz+wCin3RcarLDMDxdBNab3WDaG+itK\nHxPds7d2qhoRa098AUzuEWIDsU/ruy4pxsdyLhvSYWjs4k5fw3gdi9n2urdn\nwdJB\r\n=pFUx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEnTEd6tpOvmKjnedcsyrts1Y6BlkjDBK0aLM4mivIijAiB2WlUQbLfSpysIDXB4fHY8xt6+kPUuDxBWT2dz6lWffA=="}]},"_npmUser":{"name":"vitor.salgado","email":"vsalgadopb@gmail.com"},"directories":{},"maintainers":[{"name":"vitor.salgado","email":"vsalgadopb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/opossum-circuit-breaker_3.1.0_1641191473043_0.6964240403990338"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-02T23:55:33.176Z","3.0.0":"2022-01-02T23:55:33.407Z","modified":"2022-04-05T05:40:53.551Z","3.1.0":"2022-01-03T06:31:13.180Z"},"maintainers":[{"name":"vitor.salgado","email":"vsalgadopb@gmail.com"}],"description":"Opossum implementation for Drizzle-HTTP","homepage":"https://github.com/vitorsalgado/drizzle-http/tree/main/packages/drizzle-opossum-circuit-breaker","keywords":["drizzle-http","circuit-breaker","circuit breaker","circuitbreaker","resilience","fail-fast","http","api","rest","decorators"],"repository":{"type":"git","url":"git+https://github.com/vitorsalgado/drizzle-http.git","directory":"packages/drizzle-opossum-circuit-breaker"},"author":{"name":"Vitor Hugo Salgado","url":"https://github.com/vitorsalgado"},"bugs":{"url":"https://github.com/vitorsalgado/drizzle-http/issues"},"license":"MIT","readme":"# Opossum Circuit Breaker Adapter &middot; [![ci](https://github.com/vitorsalgado/drizzle-http/workflows/ci/badge.svg)](https://github.com/vitorsalgado/drizzle-http/actions) [![npm (scoped)](https://img.shields.io/npm/v/@drizzle-http/opossum-circuit-breaker)](https://www.npmjs.com/package/@drizzle-http/opossum-circuit-breaker) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/vitorsalgado/drizzle-http/blob/main/LICENSE)\n\nCircuit breaker adapter with [Opossum](https://github.com/nodeshift/opossum).\n\n## Installation\n\nMake sure we have the core module [@Drizzle-Http/core](https://www.npmjs.com/package/@drizzle-http/core) installed.\n\n```\nnpm i @drizzle-http/core\nnpm i @drizzle-http/opossum-circuit-breaker\n```\n\n## Usage\n\nUsage typically looks like the example below:\n\n```typescript\nimport { CircuitBreakerCallAdapterFactory } from \"@drizzle-http/opossum-circuit-breaker\";\nimport { DrizzleBuilder } from \"@drizzle-http/core\";\nimport { UndiciCallFactory } from \"@drizzle-http/undici\";\nimport { CircuitBreaker } from \"@drizzle-http/opossum-circuit-breaker\";\nimport { Fallback } from \"@drizzle-http/opossum-circuit-breaker\";\nimport { GET } from \"@drizzle-http/core\";\n\nclass CustomerApi {\n  @GET('/customers')\n  @CircuitBreaker({ /* Opossum CircuitBreaker.Options */ })\n  @Fallback('customersAlt')\n  customers(): Promise<Customer[]> { }\n}\n\nclass CustomerApiFallbacks {\n  customersAlt(id: string, error: Error): Promise<Customer> {\n    // Fallback implementation\n  }\n}\n\nconst factory = new CircuitBreakerCallAdapterFactory({ options: { /* global options */ }, fallbacks: new CustomerApiFallbacks() })\nconst api = DrizzleBuilder\n  .newBuilder()\n  .baseUrl(/* base url */)\n  .callFactory(new UndiciCallFactory())\n  .addCallAdapterFactories(factory)\n  .build()\n  .create(CustomerApi)\n```\n\n## Features\n\nAll functionalities from [Opossum](https://github.com/nodeshift/opossum) are available.  \nSome features and extensions:\n\n### Fallback\n\nFallback methods follow Opossum specification, same argument list and an error argument at the end.  \nThere are 3 ways to specify a fallback for a circuit breaker:\n\n- Specify a fallback class in `CircuitBreakerCallAdapterFactory` constructor. If a method name matches the one specified\n  in the API class, it will be used as a fallback automatically.\n- Apply the decorator `@Fallback()` and:\n  * If `@Fallback()` decorator argument is a string, it will try to find the method on the fallback class specified in\n    the `CircuitBreakerCallAdapterFactory` constructor.\n  * If `@Fallback` decorator receives a function, this function will be the fallback.\n\n> Make sure the fallback methods have right signature: same argument list + error at the end and same return type.\n\n### Registry\n\nAll circuit breakers associated with a CircuitBreakerCallAdapterFactory are stored in a registry instance.\n`CircuitBreakerCallAdapterFactory` accepts a parameter `registry`. You can pass a custom `Registry` implementation.\n\n> The circuit breaker instance is only stored in the registry after the first execution. If you want to change the circuit breaker behaviour, prefer to use a LifeCycleListener implementation.\n","readmeFilename":"README.md"}