Help us shape the future of Go! Take the 2026 Go Developer Survey

tools

package
v0.9.78 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BufferSize1024  = 2 << 10
	BufferSize2048  = 2 << 11
	BufferSize4096  = 2 << 12
	BufferSize8192  = 2 << 13
	BufferSize16384 = 2 << 14
	BufferSize32768 = 2 << 15
	BufferSize65536 = 2 << 16
)
View Source
const ValidateRulesTagName = "v"

Variables

This section is empty.

Functions

func GetRequestIDFromContext

func GetRequestIDFromContext(ctx context.Context) string

func MonkeyTime

func MonkeyTime(with time.Time) func()

nolint:unused MonkeyTime patches time.Now() function to return predefined value

func SetRequestIDToContext

func SetRequestIDToContext(ctx context.Context, requestID string) context.Context

func SlogContextWrapper

func SlogContextWrapper(h slog.Handler) slog.Handler

func TraceNoReturn

func TraceNoReturn(
	ctx context.Context,
	tracerName string,
	spanName string,
	fn func(context.Context),
)

func TraceReturnErr

func TraceReturnErr(
	ctx context.Context,
	tracerName string,
	spanName string,
	fn func(context.Context) error,
) error

func TraceReturnT

func TraceReturnT[T any](
	ctx context.Context,
	tracerName string,
	spanName string,
	fn func(context.Context) T,
) T

func TraceReturnTWithErr

func TraceReturnTWithErr[T any](
	ctx context.Context,
	tracerName string,
	spanName string,
	fn func(context.Context) (T, error),
) (T, error)

func ValidateStructCompact

func ValidateStructCompact(s interface{}) error

ValidateStructCompact calls ValidateStruct but returns single error instance

Types

type ContextFieldsHandler

type ContextFieldsHandler struct {
	slog.Handler
}

ContextFieldsHandler is wrapper around slog handler which automatically adds predefined fields to logs taking values from context.

func (*ContextFieldsHandler) Handle

func (*ContextFieldsHandler) WithAttrs

func (h *ContextFieldsHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*ContextFieldsHandler) WithGroup

func (h *ContextFieldsHandler) WithGroup(name string) slog.Handler

type PriorityQueue

type PriorityQueue[T any] struct {
	// contains filtered or unexported fields
}

PriorityQueue is a simple priority queue implementation with FIFO per Priority.

func NewPriorityQueue

func NewPriorityQueue[T any]() *PriorityQueue[T]

func (*PriorityQueue[T]) Dequeue

func (pq *PriorityQueue[T]) Dequeue() (T, bool)

func (*PriorityQueue[T]) Enqueue

func (pq *PriorityQueue[T]) Enqueue(priority int, value T)

func (*PriorityQueue[T]) Extract

func (pq *PriorityQueue[T]) Extract() []T

func (*PriorityQueue[T]) IsEmpty

func (pq *PriorityQueue[T]) IsEmpty() bool

type RateLimiter

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

RateLimiter applies a cache-backed rate limit to hashed, namespaced client keys.

func NewRateLimiter

func NewRateLimiter(
	cache cacheAccessor,
	namespace string,
	rate int,
	burst int,
	ttl time.Duration,
) *RateLimiter

func (*RateLimiter) Limit

func (m *RateLimiter) Limit(ctx context.Context, key string) (bool, error)

type ValidationError

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

func ValidateStruct

func ValidateStruct(s interface{}) []ValidationError

ValidateStruct validates arbitrary struct

func (ValidationError) Code

func (e ValidationError) Code() string

func (ValidationError) Detail

func (e ValidationError) Detail() string

func (ValidationError) Pointer

func (e ValidationError) Pointer() string

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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