v1.4.1
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
|
||||
|
||||
package ratelimit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
|
||||
)
|
||||
|
||||
// Bandwidth lossy bandwidth limiter
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
|
||||
|
||||
package ratelimit_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/ratelimit"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/testutils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBandwidth(t *testing.T) {
|
||||
@@ -16,8 +17,8 @@ func TestBandwidth(t *testing.T) {
|
||||
|
||||
var bandwidth = ratelimit.NewBandwidth(32 << 10)
|
||||
bandwidth.Ack(context.Background(), 123)
|
||||
bandwidth.Ack(context.Background(), 16 << 10)
|
||||
bandwidth.Ack(context.Background(), 32 << 10)
|
||||
bandwidth.Ack(context.Background(), 16<<10)
|
||||
bandwidth.Ack(context.Background(), 32<<10)
|
||||
}
|
||||
|
||||
func TestBandwidth_0(t *testing.T) {
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
package ratelimit
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/zero"
|
||||
"sync"
|
||||
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/zero"
|
||||
)
|
||||
|
||||
type Counter struct {
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
package ratelimit_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/ratelimit"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/testutils"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/ratelimit"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/testutils"
|
||||
)
|
||||
|
||||
func TestCounter_ACK(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user