Home / File/ manager.go — fiber Source File

manager.go — fiber Source File

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

File go FiberMiddleware Security 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  b392c21a_096a_b10e_dfed_f88342b53066["manager.go"]
  cc7104af_aece_1fe5_3985_791c7f34910c["context"]
  b392c21a_096a_b10e_dfed_f88342b53066 --> cc7104af_aece_1fe5_3985_791c7f34910c
  style b392c21a_096a_b10e_dfed_f88342b53066 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package limiter

import (
	"context"
	"fmt"
	"sync"
	"time"

	"github.com/gofiber/fiber/v3"
	"github.com/gofiber/fiber/v3/internal/memory"
)

// msgp -file="manager.go" -o="manager_msgp.go" -tests=false -unexported
//
//go:generate msgp -o=manager_msgp.go -tests=false -unexported
type item struct {
	currHits int
	prevHits int
	exp      uint64
}

//msgp:ignore manager
type manager struct {
	pool       sync.Pool
	memory     *memory.Storage
	storage    fiber.Storage
	redactKeys bool
}

const redactedKey = "[redacted]"

func newManager(storage fiber.Storage, redactKeys bool) *manager {
	// Create new storage handler
	manager := &manager{
		pool: sync.Pool{
			New: func() any {
				return new(item)
			},
		},
		redactKeys: redactKeys,
	}
	if storage != nil {
		// Use provided storage if provided
		manager.storage = storage
	} else {
		// Fallback too memory storage
		manager.memory = memory.New()
	}
	return manager
}

// acquire returns an *entry from the sync.Pool
func (m *manager) acquire() *item {
	return m.pool.Get().(*item) //nolint:forcetypeassert,errcheck // We store nothing else in the pool
}

// release and reset *entry to sync.Pool
func (m *manager) release(e *item) {
	e.prevHits = 0
	e.currHits = 0
// ... (62 more lines)

Subdomains

Functions

Dependencies

  • context

Frequently Asked Questions

What does manager.go do?
manager.go is a source file in the fiber codebase, written in go. It belongs to the FiberMiddleware domain, Security subdomain.
What functions are defined in manager.go?
manager.go defines 1 function(s): newManager.
What does manager.go depend on?
manager.go imports 1 module(s): context.
Where is manager.go in the architecture?
manager.go is located at middleware/limiter/manager.go (domain: FiberMiddleware, subdomain: Security, directory: middleware/limiter).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free