config: add a read limit option to the connection.
By default, the read limit is never set by NewConnection. When using the default pool dialer, a read limit of 512KB is set. When the read limit option is set, all sockets passed to NewConnection have that read limit set.
This commit is contained in:
@@ -349,6 +349,13 @@ func (p *Pool) Connect(url string, opts ...ConnectOption) error {
|
||||
}
|
||||
dialFn := func(ctx context.Context) (types.Socket, error) {
|
||||
socket, _, err := p.dialer.DialContext(ctx, url, hdr)
|
||||
|
||||
// Set a sane read limit when using the default dialer
|
||||
// Can be overridden with ConnectionConfig.ReadLimit
|
||||
if socket != nil {
|
||||
socket.SetReadLimit(512 * 1024)
|
||||
}
|
||||
|
||||
return socket, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user