Home / File/ limiter_test.go — fiber Source File

limiter_test.go — fiber Source File

Architecture documentation for limiter_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberMiddleware Session 1 imports 51 functions 3 classes

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)

Subdomains

Functions

Dependencies

  • context

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