util

package
v3.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogHandler

func LogHandler(config *model.LoggerConfig) slog.Handler

LogHandler returns the application log handler with the configured level.

func ToExitVal

func ToExitVal(err error) int

ToExitVal returns an exit value for the error.

Types

type IPAddress

type IPAddress string

IPAddress represents an IP address string.

type IPRateLimiter

type IPRateLimiter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

IPRateLimiter represents a rate limiter based on an IP address.

func NewIPRateLimiter

func NewIPRateLimiter(tps rate.Limit, size int) *IPRateLimiter

NewIPRateLimiter returns a new IPRateLimiter.

func (*IPRateLimiter) AddLimiter

func (ipLimiter *IPRateLimiter) AddLimiter(ipAddr string) *rate.Limiter

AddLimiter creates a new rate limiter and adds it to the limiters map, using the IP address as the key.

func (*IPRateLimiter) GetLimiter

func (ipLimiter *IPRateLimiter) GetLimiter(ipAddr string) *rate.Limiter

GetLimiter returns the rate limiter for the provided IP address if it exists. Otherwise calls AddLimiter to add a new limiter to the map.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL