-
Notifications
You must be signed in to change notification settings - Fork 180
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
[Access] Implement keepalive routine with ping-ponging to ws connection in ws controller #6757
[Access] Implement keepalive routine with ping-ponging to ws connection in ws controller #6757
Conversation
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6639-ws-ping-pong
…drukhiv/6639-ws-ping-pong
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6757 +/- ##
==========================================
+ Coverage 40.96% 41.04% +0.08%
==========================================
Files 2093 2095 +2
Lines 184478 184618 +140
==========================================
+ Hits 75577 75785 +208
+ Misses 102579 102470 -109
- Partials 6322 6363 +41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6638-ws-connection-configuring
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.
After the first round of review - looks cool!
s.Require().True(ok) | ||
msg, err := json.Marshal(requestMessage) | ||
s.Require().NoError(err) | ||
*reqMsg = msg |
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.
what does this do? isn't reqMsg
a local variable that's thrown away at the end of the function?
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.
The idea of this code is to update the first argument of ReadJSON
. Even though reqMsg
is a local variable, it serves as a pointer to the argument passed into the mock. By modifying *reqMsg
, the code changes the actual memory location that the pointer refers to.
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.
why is this needed vs passing the info in somehow? Can you add some comments explaining. it's unclear to me so it will most likely be unclear to the next person that works on these tests.
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.
let's do it like that
conn.On("ReadJSON", requestMessage).
Return(nil).
Once()
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.
let's do it like that
conn.On("ReadJSON", requestMessage). Return(nil). Once()
This will not be worked cause, the strict pointer comparison by the mock library expects the exact pointer passed during the mock setup to be the same as the pointer passed during runtime. Since these pointers are not the same, the mock is not triggered.
As I understand, to properly mock the ReadJSON
call, there are 2 options:
- Use
mock.Anything
as argument and then modify the argument inside theRun()
callback. (This approach is implemented in current test) - Use mock.
MatchedBy
, something like
s.connection.On("ReadJSON", mock.MatchedBy(func(arg interface{}) bool {
rawMsg, ok := arg.(*json.RawMessage)
if !ok {
return false
}
*rawMsg = msg
return true
})).
Return(nil).
Once()
I’ve added a detailed comment in the code explaining why ReadJSON
is mocked this way
s.Require().True(ok) | ||
msg, err := json.Marshal(requestMessage) | ||
s.Require().NoError(err) | ||
*reqMsg = msg |
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.
why is this needed vs passing the info in somehow? Can you add some comments explaining. it's unclear to me so it will most likely be unclear to the next person that works on these tests.
Co-authored-by: Andrii Slisarchuk <[email protected]>
…R-O-K/flow-go into UlyanaAndrukhiv/6639-ws-ping-pong
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 do not have any more comments for this PR. LGTM!
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.
added a few small comments, but otherwise looks good.
Closes: #6638, #6639
Context
In this pull request implemented a
keepalive
routine to monitorWebSocket
network connectivity using ping-pong messages.Key Changes
keepalive
logic with forWebSocket
controller to detect and handle connectivity issues and ensured thekeepalive
operates independently, managing ping-pong messages and monitoring connection health.WebSocket
connection and gracefully shut down affected components when issues are detected.