* 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>
26 строки
663 B
Go
26 строки
663 B
Go
// Package pool contains helpers for pooling structures distinguishable by
|
|
// size.
|
|
//
|
|
// Quick example:
|
|
//
|
|
// import "github.com/gobwas/pool"
|
|
//
|
|
// func main() {
|
|
// // Reuse objects in logarithmic range from 0 to 64 (0,1,2,4,6,8,16,32,64).
|
|
// p := pool.New(0, 64)
|
|
//
|
|
// buf, n := p.Get(10) // Returns buffer with 16 capacity.
|
|
// if buf == nil {
|
|
// buf = bytes.NewBuffer(make([]byte, n))
|
|
// }
|
|
// defer p.Put(buf, n)
|
|
//
|
|
// // Work with buf.
|
|
// }
|
|
//
|
|
// There are non-generic implementations for pooling:
|
|
// - pool/pbytes for []byte reuse;
|
|
// - pool/pbufio for *bufio.Reader and *bufio.Writer reuse;
|
|
//
|
|
package pool
|