-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Methods to read/write on plain io.{Reader,Writer} #186
Comments
I am not in favor of these functions because they make the package more complicated. Please describe the buffers that are a concern for your application and how your application will do things differently. |
I think there could not be any complication with optional extraction of buffers from conn. So pseudocode could look like this: var epolledConns chan net.Conn
for conn := range epolledConns {
var buf *bufio.Reader
buf = acquireBuffer(conn, readBufferSize)
bts, typ, err := websocket.ReadFrame(buf)
// ...
} |
By the way, it is very conformable with this issue too. |
I will not add a feature that requires the app to use epoll directly to make the feature useful. You should copy the package and modify it to meet your needs. The proposed feature makes the package more complicated for users because it introduces a second way of using the package. |
It is not required for the app to use epoll directly. For example, you always know when you want to write data to the socket – so you dont need to keep write buffer for idle connections. With read it also could be useful when you just want to read response after you wrote request. |
Alternatively, it is possible just to implement exported constructor of |
The application must read the connection to process control messages.
How will be bufio.Reader differ from the one created by the package? The package does not use a bufio.Writer. |
It will not differ, it will be the same, but reused. |
New features require a justification and must be useful to more than one application. Describe why reusing these buffers will provide a significant performance improvement to your application and how this feature might be useful to other applications. |
Reusing these buffers will not increase performance. It will be at most the same. But, it will reduce the memory consumption by the application. And this is actual for projects with lots of idle connections. |
Are you planning to share the buffers between connections? You will not decrease the memory required by the application if you reuse buffers as connections are opened and closed. |
Yes, I am planning to share the buffers between connections. But I will reuse them not on conn open/close, but on conn ready to read/write. |
It is not possible to share read buffers without use epoll. I will not add a feature that requires the app to use epoll directly to make the feature useful. You should copy the package and modify it to meet your needs. |
I have work in progress to fix #9. You will have complete control of the write buffer when this work is complete. |
Sounds useful. Thanks. |
Hello!
Thank you for the great library! 🚀
In application I developing it is very hard restrictions on memory consumption.
So I need to reuse very lot of things, and, of course, buffers.
Is it possible to export some io methods for just to do handshake on plain
net.Conn
orio.ReadWriter
, and read/write functions on it?I mean something like this:
The text was updated successfully, but these errors were encountered: