Skip to content

Commit

Permalink
Complete createServicePolicy (#5149)
Browse files Browse the repository at this point in the history
This commit is a continuation of a previous commit which added a utility
function for use in service classes which ensures that they follow the
circuit breaker and retry patterns.

This commit completes the function by adding:

- `retryFilterPolicy`, which allows for retrying certain errors and not
handling others.
- `maxRetries`, which allows for giving up early before the max
consecutive failures is reached. Note that because this can combine with
`maxConsecutiveFailures`, it adds a bunch of other code paths and so
this requires adding a lot of new tests.
  • Loading branch information
mcmire authored Jan 22, 2025
1 parent 77f5051 commit aec3860
Show file tree
Hide file tree
Showing 6 changed files with 2,286 additions and 608 deletions.
5 changes: 2 additions & 3 deletions eslint-warning-thresholds.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
"@typescript-eslint/no-unused-vars": 41,
"@typescript-eslint/prefer-promise-reject-errors": 33,
"@typescript-eslint/prefer-readonly": 147,
"@typescript-eslint/switch-exhaustiveness-check": 0,
"import-x/namespace": 189,
"import-x/no-named-as-default": 1,
"import-x/no-named-as-default-member": 8,
"import-x/order": 211,
"jest/no-conditional-in-test": 138,
"jest/no-conditional-in-test": 113,
"jest/prefer-lowercase-title": 2,
"jest/prefer-strict-equal": 2,
"jsdoc/check-tag-names": 375,
"jsdoc/require-returns": 25,
"jsdoc/tag-lines": 335,
"n/no-unsupported-features/node-builtins": 14,
"n/no-unsupported-features/node-builtins": 4,
"n/prefer-global/text-encoder": 4,
"n/prefer-global/text-decoder": 4,
"prettier/prettier": 116,
Expand Down
3 changes: 2 additions & 1 deletion packages/controller-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add `createServicePolicy` function to assist with reducing boilerplate for service classes ([#5154](https://github.com/MetaMask/core/pull/5154), [#5143](https://github.com/MetaMask/core/pull/5143))
- Add `createServicePolicy` function to assist with reducing boilerplate for service classes ([#5154](https://github.com/MetaMask/core/pull/5154), [#5143](https://github.com/MetaMask/core/pull/5143), [#5149](https://github.com/MetaMask/core/pull/5149))
- Also add `DEFAULT_CIRCUIT_BREAK_DURATION`, `DEFAULT_DEGRADED_THRESHOLD`, `DEFAULT_MAX_CONSECUTIVE_FAILURES`, and `DEFAULT_MAX_RETRIES` constants and `IServicePolicy` type

## [11.4.5]

Expand Down
Loading

0 comments on commit aec3860

Please sign in to comment.