hopp: Add SetDeadline methods to Conn and Trans

This commit is contained in:
2025-09-05 18:48:12 -04:00
parent 44fb561758
commit 12fbfa6293
3 changed files with 92 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ package hopp
import "io"
import "net"
import "time"
import "bytes"
import "errors"
import "context"
@@ -50,6 +51,10 @@ func (this *b) SetSizeLimit(limit int64) {
this.sizeLimit = limit
}
func (this *b) SetDeadline(t time.Time) error {
return this.underlying.SetDeadline(t)
}
func (this *b) newTrans(underlying Stream) *transB {
return &transB {
sizeLimit: this.sizeLimit,
@@ -124,6 +129,10 @@ func (this *transB) receiveReader() (uint16, int64, io.Reader, error) {
return method, size, data, nil
}
func (this *transB) SetDeadline(t time.Time) error {
return this.underlying.SetDeadline(t)
}
type writerB struct {
parent *transB
buffer bytes.Buffer
@@ -149,12 +158,16 @@ type MultiConn interface {
AcceptStream(context.Context) (Stream, error)
// OpenStream opens a new stream.
OpenStream() (Stream, error)
// See the documentation for [net.Conn.SetDeadline].
SetDeadline(time.Time) error
}
// Stream represents a single stream returned by a [MultiConn].
type Stream interface {
// See documentation for [net.Conn].
io.ReadWriteCloser
// See the documentation for [net.Conn.SetDeadline].
SetDeadline(time.Time) error
// ID returns the stream ID
ID() int64
}