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
+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
}