可以在集群设置中修改节点最大并发读/写数

This commit is contained in:
刘祥超
2024-04-30 19:09:40 +08:00
parent 33156fed2a
commit 7ec4656aea
5 changed files with 115 additions and 10 deletions

View File

@@ -6,10 +6,32 @@ import (
fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs"
"github.com/TeaOSLab/EdgeNode/internal/utils/testutils"
"github.com/iwind/TeaGo/assert"
"math/rand"
"sync"
"testing"
"time"
)
func TestLimiter_SetThreads(t *testing.T) {
var limiter = fsutils.NewLimiter(4)
var concurrent = 1024
var wg = sync.WaitGroup{}
wg.Add(concurrent)
for i := 0; i < concurrent; i++ {
go func() {
defer wg.Done()
limiter.SetThreads(rand.Int() % 128)
limiter.TryAck()
}()
}
wg.Wait()
}
func TestLimiter_Ack(t *testing.T) {
var a = assert.NewAssertion(t)