-
Notifications
You must be signed in to change notification settings - Fork 179
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
Open
UlyanaAndrukhiv
wants to merge
22
commits into
onflow:master
Choose a base branch
from
The-K-R-O-K:UlyanaAndrukhiv/6639-ws-ping-pong
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
81ddee5
Added Websocket connection configurating
UlyanaAndrukhiv 808b54b
Updated configureConnection and godoc
UlyanaAndrukhiv 6c5ab5d
Adedd SetWriteDeadline before write operation
UlyanaAndrukhiv eec15e5
Set initital read deadline, updated godoc
UlyanaAndrukhiv fd567aa
Merge branch 'master' into UlyanaAndrukhiv/6638-ws-connection-configu…
UlyanaAndrukhiv 098c10d
Merge branch 'master' into UlyanaAndrukhiv/6638-ws-connection-configu…
UlyanaAndrukhiv 917bbde
Implemented ping-pong ws routine, refactored shutdownConnection
UlyanaAndrukhiv 438b130
Merge branch 'UlyanaAndrukhiv/6638-ws-connection-configuring' of gith…
UlyanaAndrukhiv 86cdb35
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into UlyanaAn…
UlyanaAndrukhiv ec4e247
Added more comments and updated godoc
UlyanaAndrukhiv eae6bbf
Moved constants to new websockets package according to comment
UlyanaAndrukhiv 4e2d35c
Merge branch 'UlyanaAndrukhiv/6638-ws-connection-configuring' of gith…
UlyanaAndrukhiv 9971188
Merge branch 'master' into UlyanaAndrukhiv/6638-ws-connection-configu…
UlyanaAndrukhiv 6cd2841
Merged with UlyanaAndrukhiv/6638-ws-connection-configuring
UlyanaAndrukhiv c90d75f
Updated according to comments, added unit tests for ping-pong functio…
UlyanaAndrukhiv afc8648
Merge branch 'master' into UlyanaAndrukhiv/6639-ws-ping-pong
UlyanaAndrukhiv 040a949
Updated WriteMessage to WriteControl for Ping messages, updated mocks…
UlyanaAndrukhiv 357dc2f
Merge branch 'master' into UlyanaAndrukhiv/6639-ws-ping-pong
UlyanaAndrukhiv 276ea7e
Added tests for keepalive, configure connection, graceful shutdown, a…
UlyanaAndrukhiv 077c543
Merge branch 'UlyanaAndrukhiv/6639-ws-ping-pong' of github.com:The-K-…
UlyanaAndrukhiv 21259ce
Added happy case test for keepalive
UlyanaAndrukhiv 1f5728d
Updated unit test for keep alive
UlyanaAndrukhiv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package websockets | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/gorilla/websocket" | ||
) | ||
|
||
type WebsocketConnection interface { | ||
ReadJSON(v interface{}) error | ||
WriteJSON(v interface{}) error | ||
WriteControl(messageType int, deadline time.Time) error | ||
Close() error | ||
SetReadDeadline(deadline time.Time) error | ||
SetWriteDeadline(deadline time.Time) error | ||
SetPongHandler(h func(string) error) | ||
} | ||
|
||
type WebsocketConnectionImpl struct { | ||
conn *websocket.Conn | ||
} | ||
|
||
func NewWebsocketConnection(conn *websocket.Conn) *WebsocketConnectionImpl { | ||
return &WebsocketConnectionImpl{ | ||
conn: conn, | ||
} | ||
} | ||
|
||
var _ WebsocketConnection = (*WebsocketConnectionImpl)(nil) | ||
|
||
func (c *WebsocketConnectionImpl) ReadJSON(v interface{}) error { | ||
return c.conn.ReadJSON(v) | ||
} | ||
|
||
func (c *WebsocketConnectionImpl) WriteJSON(v interface{}) error { | ||
return c.conn.WriteJSON(v) | ||
} | ||
|
||
func (c *WebsocketConnectionImpl) WriteControl(messageType int, deadline time.Time) error { | ||
return c.conn.WriteControl(messageType, nil, deadline) | ||
} | ||
|
||
func (c *WebsocketConnectionImpl) Close() error { | ||
return c.conn.Close() | ||
} | ||
|
||
func (c *WebsocketConnectionImpl) SetReadDeadline(deadline time.Time) error { | ||
return c.conn.SetReadDeadline(deadline) | ||
} | ||
|
||
func (c *WebsocketConnectionImpl) SetWriteDeadline(deadline time.Time) error { | ||
return c.conn.SetWriteDeadline(deadline) | ||
} | ||
|
||
func (c *WebsocketConnectionImpl) SetPongHandler(h func(string) error) { | ||
c.conn.SetPongHandler(h) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 has this file name been changed to
connections
?