-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include endpointUrl in RpcService event listener data #5225
Conversation
0fb406d
to
3ef16d9
Compare
Modify RpcService so that when it emits the `onRetry`, `onBreak`, or `onDegraded` event, it passes the URL of the endpoint it is requesting to the respective event listener. This will be useful when we add the ability to create a chain of RPC service objects, where we start out hitting a primary node and then keep failing over to successive nodes in the chain until the request succeeds. By including the endpoint URL in the event listener data, we are able to identify which RPC service was active when the event occurred.
3ef16d9
to
c9c747f
Compare
@@ -18,7 +18,7 @@ module.exports = merge(baseConfig, { | |||
coverageThreshold: { | |||
global: { | |||
branches: 78.12, | |||
functions: 80.7, | |||
functions: 80.35, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked the coverage report and all of the lines I added are tested.
@@ -203,27 +207,21 @@ export function createServicePolicy({ | |||
}); | |||
const onBreak = circuitBreakerPolicy.onBreak.bind(circuitBreakerPolicy); | |||
|
|||
const onDegradedListeners: (() => void)[] = []; | |||
const onDegradedEventEmitter = new CockatielEventEmitter<void>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are reusing the Cockatiel built-in EventEmitter class instead of implementing the EventEmitter pattern ourselves. We do this because we want the signature of the onDegraded
method to match the signatures for onRetry
and onBreak
(onDegraded
is a custom hook we add, whereas onRetry
and onBreak
essentially come directly from Cockatiel).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Explanation
Modify RpcService so that when it emits the
onRetry
,onBreak
, oronDegraded
event, it passes the URL of the endpoint it is requesting to the respective event listener.This will be useful when we add the ability to create a chain of RPC service objects, where we start out hitting a primary node and then keep failing over to successive nodes in the chain until the request succeeds. By including the endpoint URL in the event listener data, we are able to identify which RPC service was active when the event occurred.
References
Progresses #5222.
Changelog
(Updated in PR.)
Checklist