Versions in this module Expand all Collapse all v1 v1.0.0 Jul 12, 2026 Changes in this version + var ErrCircuitOpen = errors.New("resilium: circuit breaker is open") + var ErrMaxAttemptsExceeded = errors.New("resilium: max retry attempts exceeded") + var ErrRateLimited = errors.New("resilium: rate limit exceeded") + var ErrTimeout = errors.New("resilium: operation timed out") + func Execute[T any](ctx context.Context, p *Policy, op Operation[T]) (T, error) + type Hooks struct + OnCircuitClose func(name string) + OnCircuitOpen func(name string) + OnRateLimited func() + OnRetry func(attempt int, err error) + OnTimeout func() + type Middleware func(next OperationFunc) OperationFunc + type Operation func(ctx context.Context) (T, error) + type OperationFunc func(ctx context.Context) (any, error) + type Option func(*Policy) + func WithCircuitBreaker(cfg circuitbreaker.Config) Option + func WithHooks(h Hooks) Option + func WithLogger(logger *slog.Logger) Option + func WithRateLimit(requestsPerSecond float64, burst int) Option + func WithRetry(cfg retry.Config) Option + func WithTimeout(d time.Duration) Option + type Policy struct + func New(opts ...Option) *Policy