good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
websocket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
github
nhooyr
websocket
Commits
ac32d3f5
Unverified
Commit
ac32d3f5
authored
Sep 23, 2019
by
Anmol Sethi
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup README language
parent
676bb696
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+13
-14
13 additions, 14 deletions
README.md
with
13 additions
and
14 deletions
README.md
+
13
−
14
View file @
ac32d3f5
...
@@ -110,26 +110,25 @@ https://github.com/gorilla/websocket
...
@@ -110,26 +110,25 @@ https://github.com/gorilla/websocket
This package is the community standard but it is 6 years old and over time
This package is the community standard but it is 6 years old and over time
has accumulated cruft. There are too many ways to do the same thing.
has accumulated cruft. There are too many ways to do the same thing.
Just compare the godoc of
Just compare the godoc of
[
nhooyr/websocket
](
https://godoc.org/nhooyr.io/websocket
)
side by side
with
[
nhooyr/websocket
](
https://godoc.org/nhooyr.io/websocket
)
with
[
gorilla/websocket
](
https://godoc.org/github.com/gorilla/websocket
)
.
[
gorilla/websocket
](
https://godoc.org/github.com/gorilla/websocket
)
side by side
.
The API for nhooyr/websocket has been designed such that there is only one way to do things
The API for nhooyr/websocket has been designed such that there is only one way to do things
.
w
hi
ch
makes it easy to use correctly. Not only is the API simpler, the implementation is
T
hi
s
makes it easy to use correctly. Not only is the API simpler, the implementation is
only 2200 lines whereas gorilla/websocket is at 3500 lines. That's more code to maintain,
only 2200 lines whereas gorilla/websocket is at 3500 lines. That's more code to maintain,
more code to test, more code to document and more surface area for bugs.
more code to test, more code to document and more surface area for bugs.
Moreover, nhooyr/websocket
has
support
for
newer Go idioms such as context.Context
and
Moreover, nhooyr/websocket support
s
newer Go idioms such as context.Context
.
also uses net/http's Client and ResponseWriter directly for WebSocket handshakes.
It
also uses net/http's Client and ResponseWriter directly for WebSocket handshakes.
gorilla/websocket writes its handshakes to the underlying net.Conn
which means
gorilla/websocket writes its handshakes to the underlying net.Conn
.
it has to reinvent hooks for TLS and proxies and prevents support of HTTP/2.
Thus
it has to reinvent hooks for TLS and proxies and prevents support of HTTP/2.
Some more advantages of nhooyr/websocket are that it supports concurrent writes and
Some more advantages of nhooyr/websocket are that it supports concurrent writes and
makes it very easy to close the connection with a status code and reason.
makes it very easy to close the connection with a status code and reason.
The ping API is also nicer. gorilla/websocket requires registering a pong handler on the Conn
The ping API is also nicer. gorilla/websocket requires registering a pong handler on the Conn
which results in awkward control flow. With nhooyr/websocket you use the Ping method on the Conn
which results in awkward control flow. With nhooyr/websocket you use the Ping method on the Conn
that sends a ping and also waits for the pong, though you must be reading from the connection
that sends a ping and also waits for the pong.
for the pong to be read.
Additionally, nhooyr.io/websocket can compile to
[
WASM
](
https://godoc.org/nhooyr.io/websocket#hdr-WASM
)
for the browser.
Additionally, nhooyr.io/websocket can compile to
[
WASM
](
https://godoc.org/nhooyr.io/websocket#hdr-WASM
)
for the browser.
...
@@ -137,7 +136,7 @@ In terms of performance, the differences mostly depend on your application code.
...
@@ -137,7 +136,7 @@ In terms of performance, the differences mostly depend on your application code.
reuses message buffers out of the box if you use the wsjson and wspb subpackages.
reuses message buffers out of the box if you use the wsjson and wspb subpackages.
As mentioned above, nhooyr/websocket also supports concurrent writers.
As mentioned above, nhooyr/websocket also supports concurrent writers.
The only performance con to nhooyr/websocket is that uses one extra goroutine to support
The only performance con to nhooyr/websocket is that
it
uses one extra goroutine to support
cancellation with context.Context. This costs 2 KB of memory which is cheap compared to
cancellation with context.Context. This costs 2 KB of memory which is cheap compared to
the benefits.
the benefits.
...
@@ -161,9 +160,9 @@ effort to ensure its speed and I have applied as many of its optimizations as
...
@@ -161,9 +160,9 @@ effort to ensure its speed and I have applied as many of its optimizations as
I could into nhooyr/websocket. Definitely check out his fantastic
[
blog post
](
https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb
)
I could into nhooyr/websocket. Definitely check out his fantastic
[
blog post
](
https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb
)
about performant WebSocket servers.
about performant WebSocket servers.
If you want a library that gives you absolute control over everything, this is the library
,
If you want a library that gives you absolute control over everything, this is the library
.
b
ut for
most users, the API provided by
nhooyr/websocket will fit better
as it i
s nearly
jus
t
B
ut for
99.9% of use cases,
nhooyr/websocket will fit better
. It'
s nearly
as performan
t
as performant
but much easier to use
correctly and idiomatic
.
but much easier to use.
## Contributing
## Contributing
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment