utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package utils provides worker pool and concurrent processing utilities.

Package utils provides error handling types and contextual error wrapping.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfig     = errors.New("configuration error")
	ErrTemplate   = errors.New("template error")
	ErrContent    = errors.New("content error")
	ErrFileSystem = errors.New("filesystem error")
	ErrServer     = errors.New("server error")
	ErrParser     = errors.New("parser error")
)

Functions

func ConfigError

func ConfigError(operation, path string, err error) error

func ContentError

func ContentError(operation, filePath string, err error) error

func FileSystemError

func FileSystemError(operation, path string, err error) error

func IsCategory

func IsCategory(err error, category error) bool

func ParserError

func ParserError(operation, contentPath string, err error) error

func ServerError

func ServerError(operation string, err error) error

func TemplateError

func TemplateError(operation, templateName string, err error) error

func WrapWithContext

func WrapWithContext(err error, category error, ctx ErrorContext) error

Types

type ContextualError

type ContextualError struct {
	Err      error
	Category error
	Context  ErrorContext
}

ContextualError wraps an error with additional context.

func (*ContextualError) Error

func (e *ContextualError) Error() string

func (*ContextualError) Is

func (e *ContextualError) Is(target error) bool

Is implements error matching for both category and underlying error.

func (*ContextualError) Unwrap

func (e *ContextualError) Unwrap() error

type ErrorContext

type ErrorContext struct {
	Operation string
	Component string
	Path      string
	Details   map[string]any
}

ErrorContext provides additional context for errors.

func GetErrorContext

func GetErrorContext(err error) (ErrorContext, bool)

type WorkerPool

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

WorkerPool represents a pool of workers with Go 1.25.x enhancements.

func NewWorkerPool

func NewWorkerPool(ctx context.Context) *WorkerPool

NewWorkerPool creates a new worker pool.

func (*WorkerPool) Close

func (wp *WorkerPool) Close()

func (*WorkerPool) ProcessContentNodes

func (wp *WorkerPool) ProcessContentNodes(nodes []any, processor func(ctx context.Context, node any) error) error

ProcessContentNodes processes content nodes concurrently.

func (*WorkerPool) ProcessFiles

func (wp *WorkerPool) ProcessFiles(files []string, processor func(ctx context.Context, filePath string) error) error

ProcessFiles processes files concurrently.

Jump to

Keyboard shortcuts

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