util

package
v0.0.0-...-dc2b481 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 13 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 NewQuartzLogger

func NewQuartzLogger(ctx context.Context) logger.Logger

NewQuartzLogger returns a new QuartzLogger.

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.

type IPWhiteList

type IPWhiteList struct {
	// contains filtered or unexported fields
}

func NewIPWhiteList

func NewIPWhiteList(ipList []string) *IPWhiteList

func (*IPWhiteList) IsAllowed

func (wl *IPWhiteList) IsAllowed(ip string) bool

type QuartzLogger

type QuartzLogger struct {
	// contains filtered or unexported fields
}

QuartzLogger implements the quartz logger interface.

func (*QuartzLogger) Debug

func (l *QuartzLogger) Debug(msg any)

Debug logs at LevelDebug.

func (*QuartzLogger) Debugf

func (l *QuartzLogger) Debugf(format string, args ...any)

Debugf logs at LevelDebug.

func (*QuartzLogger) Enabled

func (l *QuartzLogger) Enabled(_ logger.Level) bool

Enabled for all.

func (*QuartzLogger) Error

func (l *QuartzLogger) Error(msg any)

Error logs at LevelError.

func (*QuartzLogger) Errorf

func (l *QuartzLogger) Errorf(format string, args ...any)

Errorf logs at LevelError.

func (*QuartzLogger) Info

func (l *QuartzLogger) Info(msg any)

Info logs at LevelInfo.

func (*QuartzLogger) Infof

func (l *QuartzLogger) Infof(format string, args ...any)

Infof logs at LevelInfo.

func (*QuartzLogger) Trace

func (l *QuartzLogger) Trace(msg any)

Trace logs at LevelTrace.

func (*QuartzLogger) Tracef

func (l *QuartzLogger) Tracef(format string, args ...any)

Tracef logs at LevelTrace.

func (*QuartzLogger) Warn

func (l *QuartzLogger) Warn(msg any)

Warn logs at LevelWarn.

func (*QuartzLogger) Warnf

func (l *QuartzLogger) Warnf(format string, args ...any)

Warnf logs at LevelWarn.

Jump to

Keyboard shortcuts

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