Skip to content

Commit

Permalink
createServicePolicy: Convert callbacks to methods
Browse files Browse the repository at this point in the history
Both RetryPolicy and CircuitBreakerPolicy from the Cockatiel library
allow for listening for events using `on*` methods. Our "service policy"
allows for listening to some of the same events as well as the
"degraded" event. For parity with Cockatiel — and for easier use in
general — this commit removes the callbacks that `createServicePolicy`
takes and replaces them with `on*` methods.
  • Loading branch information
mcmire committed Jan 23, 2025
1 parent aec3860 commit a811bf6
Show file tree
Hide file tree
Showing 4 changed files with 373 additions and 311 deletions.
6 changes: 4 additions & 2 deletions packages/controller-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ 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), [#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
- Add utility function for 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), [#5188](https://github.com/MetaMask/core/pull/5188))
- Add function `createServicePolicy`
- Add constants `DEFAULT_CIRCUIT_BREAK_DURATION`, `DEFAULT_DEGRADED_THRESHOLD`, `DEFAULT_MAX_CONSECUTIVE_FAILURES`, and `DEFAULT_MAX_RETRIES`
- Add types `ServicePolicy` and `CreateServicePolicyOptions`

## [11.4.5]

Expand Down
Loading

0 comments on commit a811bf6

Please sign in to comment.