MM-21012: Revamp websocket implementation (#16620)

* MM-21012: Revamp websocket implementation

We replace the old gorilla/websocket implementation with the
gobwas/ws library. The gorilla library was in maintenance mode
and had a high level API due to which we cannot use that for
situations where a large number of concurrent connections needs
to be supported.

The ws library is a very low-level library that allows us
to work with raw net.Conns. We make several improvements:

- We completely remove the reader goroutines, and instead
replace them with a manual epoll implementation which sends off
messages to be read when it receives any data on the connection.
This lets us scale to a much larger number of connections.
- The reader buffer is eliminated, because we directly read
from the connection now.

https://mattermost.atlassian.net/browse/MM-21012

```release-notes
Improved the websocket implementation by using epoll manually
to read from a websocket. As a result, the number of goroutines
is expected to go down by half.
```

* fix tests

* fix shadowing errors

* final changes

* windows support!

* Remove pointer to waitgroup

* Fix edge case

* Trigger CI

* Trigger CI

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2021-02-13 23:42:11 +05:30
коммит произвёл GitHub
родитель 9e561aa491
Коммит a246104d04
76 изменённых файлов: 9346 добавлений и 58 удалений

2
go.mod
Просмотреть файл

@@ -35,6 +35,7 @@ require (
github.com/go-redis/redis/v8 v8.4.9 // indirect
github.com/go-resty/resty/v2 v2.4.0 // indirect
github.com/go-sql-driver/mysql v1.5.0
github.com/gobwas/ws v1.1.0-rc.2
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/golang/snappy v0.0.2 // indirect
github.com/google/uuid v1.1.5 // indirect
@@ -66,6 +67,7 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/ledongthuc/pdf v0.0.0-20200323191019-23c5852adbd2
github.com/lib/pq v1.9.0
github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattermost/go-i18n v1.11.0
github.com/mattermost/gorp v1.6.2-0.20200624165429-2595d5e54111