hopp: Add SetDeadline methods to Conn and Trans
This commit is contained in:
13
metadaptb.go
13
metadaptb.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user