limiter_test.go — fiber Source File
Architecture documentation for limiter_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0509da96_221e_0d0d_fe2e_f2e2e3695b6f["limiter_test.go"] cc7104af_aece_1fe5_3985_791c7f34910c["context"] 0509da96_221e_0d0d_fe2e_f2e2e3695b6f --> cc7104af_aece_1fe5_3985_791c7f34910c style 0509da96_221e_0d0d_fe2e_f2e2e3695b6f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package limiter
import (
"context"
"errors"
"io"
"net/http"
"net/http/httptest"
"strconv"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/valyala/fasthttp"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/internal/storage/memory"
)
type failingLimiterStorage struct {
data map[string][]byte
errs map[string]error
}
const testLimiterClientKey = "client-key"
func newFailingLimiterStorage() *failingLimiterStorage {
return &failingLimiterStorage{
data: make(map[string][]byte),
errs: make(map[string]error),
}
}
// countingFailStorage fails set operations after a specified number of successful calls
type countingFailStorage struct {
*failingLimiterStorage
setFailErr error
setCount int
failAfterN int
}
func newCountingFailStorage(failAfterN int, err error) *countingFailStorage {
return &countingFailStorage{
failingLimiterStorage: newFailingLimiterStorage(),
failAfterN: failAfterN,
setFailErr: err,
}
}
func (s *countingFailStorage) SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error {
s.setCount++
if s.setCount > s.failAfterN {
return s.setFailErr
}
return s.failingLimiterStorage.SetWithContext(ctx, key, val, exp)
}
type contextRecord struct {
// ... (1663 more lines)
Domain
Subdomains
Functions
- Benchmark_Limiter()
- Benchmark_Limiter_Custom_Store()
- TestLimiterDefaultConfigNoPanic()
- TestLimiterFixedPropagatesRequestContextToStorage()
- TestLimiterFixedStorageGetError()
- TestLimiterFixedStorageGetErrorDisableRedaction()
- TestLimiterFixedStorageSetError()
- TestLimiterFixedStorageSetErrorDisableRedaction()
- TestLimiterFixedStorageSetErrorOnSkipSuccessfulRequests()
- TestLimiterSlidingPropagatesRequestContextToStorage()
- TestLimiterSlidingSkipsPostUpdateWhenHeadersDisabled()
- Test_Limiter_Bug_NewErrorf_SkipSuccessfulRequests_FixedWindow()
- Test_Limiter_Bug_NewErrorf_SkipSuccessfulRequests_SlidingWindow()
- Test_Limiter_Concurrency()
- Test_Limiter_Concurrency_Store()
- Test_Limiter_Disable_Headers()
- Test_Limiter_Fixed_ExpirationFuncOverridesStaticExpiration()
- Test_Limiter_Fixed_ExpirationFunc_FallbackOnNegativeDuration()
- Test_Limiter_Fixed_ExpirationFunc_FallbackOnZeroDuration()
- Test_Limiter_Fixed_Window_Custom_Storage_No_Skip_Choices()
- Test_Limiter_Fixed_Window_Custom_Storage_Skip_Failed_Requests()
- Test_Limiter_Fixed_Window_Custom_Storage_Skip_Successful_Requests()
- Test_Limiter_Fixed_Window_No_Skip_Choices()
- Test_Limiter_Fixed_Window_Skip_Failed_Requests()
- Test_Limiter_Fixed_Window_Skip_Successful_Requests()
- Test_Limiter_Headers()
- Test_Limiter_Next()
- Test_Limiter_Sliding_ExpirationFuncOverridesStaticExpiration()
- Test_Limiter_Sliding_ExpirationFunc_FallbackOnNegativeDuration()
- Test_Limiter_Sliding_ExpirationFunc_FallbackOnZeroDuration()
- Test_Limiter_Sliding_MaxFuncOverridesStaticMax()
- Test_Limiter_Sliding_Window_Custom_Storage_No_Skip_Choices()
- Test_Limiter_Sliding_Window_Custom_Storage_Skip_Failed_Requests()
- Test_Limiter_Sliding_Window_Custom_Storage_Skip_Successful_Requests()
- Test_Limiter_Sliding_Window_ExpiresStalePrevHits()
- Test_Limiter_Sliding_Window_No_Skip_Choices()
- Test_Limiter_Sliding_Window_RecalculatesAfterHandlerDelay()
- Test_Limiter_Sliding_Window_SkipFailedRequests_DecrementsPreviousWindow()
- Test_Limiter_Sliding_Window_Skip_Failed_Requests()
- Test_Limiter_Sliding_Window_Skip_Successful_Requests()
- Test_Limiter_With_Max_Func()
- Test_Limiter_With_Max_Func_With_Zero()
- Test_Limiter_With_Max_Func_With_Zero_And_Limiter_Sliding()
- Test_Sliding_Window()
- canceledContextWithMarker()
- contextRecordFrom()
- contextWithMarker()
- newContextRecorderLimiterStorage()
- newCountingFailStorage()
- newFailingLimiterStorage()
- sleepForRetryAfter()
Types
Dependencies
- context
Source
Frequently Asked Questions
What does limiter_test.go do?
limiter_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberMiddleware domain, Session subdomain.
What functions are defined in limiter_test.go?
limiter_test.go defines 51 function(s): Benchmark_Limiter, Benchmark_Limiter_Custom_Store, TestLimiterDefaultConfigNoPanic, TestLimiterFixedPropagatesRequestContextToStorage, TestLimiterFixedStorageGetError, TestLimiterFixedStorageGetErrorDisableRedaction, TestLimiterFixedStorageSetError, TestLimiterFixedStorageSetErrorDisableRedaction, TestLimiterFixedStorageSetErrorOnSkipSuccessfulRequests, TestLimiterSlidingPropagatesRequestContextToStorage, and 41 more.
What does limiter_test.go depend on?
limiter_test.go imports 1 module(s): context.
Where is limiter_test.go in the architecture?
limiter_test.go is located at middleware/limiter/limiter_test.go (domain: FiberMiddleware, subdomain: Session, directory: middleware/limiter).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free