lneto rework: Require explicit BackoffStrategy in all APIs (#116)

* make backoff explicit API

* fix tests to use explicit backoff

* fix examples with explicit tcp
This commit is contained in:
Pat Whittingslow
2026-06-09 10:20:40 -03:00
committed by GitHub
parent 3b82cefec3
commit 6ba06acdcb
28 changed files with 324 additions and 84 deletions
+3 -2
View File
@@ -25,11 +25,12 @@ func _() {
_ = x[FieldClassBinaryText-14]
_ = x[FieldClassOperation-15]
_ = x[FieldClassTimestamp-16]
_ = x[FieldClassDNSName-17]
}
const _FieldClass_name = "undefinedsourcedestinationprotocolversiontypesizeflagsidentificationchecksumoptionspayloadtextaddressbinary-textoptimestamp"
const _FieldClass_name = "undefinedsourcedestinationprotocolversiontypesizeflagsidentificationchecksumoptionspayloadtextaddressbinary-textoptimestampdns name"
var _FieldClass_index = [...]uint8{0, 9, 15, 26, 34, 41, 45, 49, 54, 68, 76, 83, 90, 94, 101, 112, 114, 123}
var _FieldClass_index = [...]uint8{0, 9, 15, 26, 34, 41, 45, 49, 54, 68, 76, 83, 90, 94, 101, 112, 114, 123, 131}
func (i FieldClass) String() string {
if i >= FieldClass(len(_FieldClass_index)-1) {
+9
View File
@@ -4,6 +4,7 @@ import (
"math/rand"
"net/netip"
"testing"
"time"
"github.com/soypat/lneto"
"github.com/soypat/lneto/tcp"
@@ -146,6 +147,7 @@ func setupClientServer6(t *testing.T, rng *rand.Rand, client, server *StackIPv6,
RxBuf: make([]byte, bufsize),
TxBuf: make([]byte, bufsize),
TxPacketQueueSize: 3,
RWBackoff: backoffYield,
})
if err != nil {
t.Fatal(err)
@@ -154,6 +156,7 @@ func setupClientServer6(t *testing.T, rng *rand.Rand, client, server *StackIPv6,
RxBuf: make([]byte, bufsize),
TxBuf: make([]byte, bufsize),
TxPacketQueueSize: 3,
RWBackoff: backoffYield,
})
if err != nil {
t.Fatal(err)
@@ -187,6 +190,7 @@ func setupClientServer(t *testing.T, rng *rand.Rand, client, server *StackIPv4,
TxBuf: make([]byte, bufsize),
TxPacketQueueSize: 3,
Logger: nil,
RWBackoff: backoffYield,
})
if err != nil {
t.Fatal(err)
@@ -196,6 +200,7 @@ func setupClientServer(t *testing.T, rng *rand.Rand, client, server *StackIPv4,
TxBuf: make([]byte, bufsize),
TxPacketQueueSize: 3,
Logger: nil,
RWBackoff: backoffYield,
})
if err != nil {
t.Fatal(err)
@@ -219,3 +224,7 @@ func setupClientServer(t *testing.T, rng *rand.Rand, client, server *StackIPv4,
t.Fatal(err)
}
}
func backoffYield(consecutiveBackoffs uint) time.Duration {
return lneto.BackoffFlagGosched
}
+2
View File
@@ -616,6 +616,7 @@ func setupClient(t *testing.T, client *StackIPv4, conn *tcp.Conn, serverAddr net
RxBuf: make([]byte, bufsize),
TxBuf: make([]byte, bufsize),
TxPacketQueueSize: 3,
RWBackoff: backoffYield,
})
if err != nil {
t.Fatal(err)
@@ -649,6 +650,7 @@ func newMockTCPPool(n, queuesize, bufsize int) *mockTCPPool {
RxBuf: make([]byte, bufsize),
TxBuf: make([]byte, bufsize),
TxPacketQueueSize: queuesize,
RWBackoff: backoffYield,
})
if err != nil {
panic(err)