Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Logging ¶ added in v0.0.6
func Logging(name string, opts ...LoggingOption) minds.Middleware
Logging creates a middleware instance for structured logging.
func Retry ¶
func Retry(name string, opts ...retry.Option) minds.Middleware
Retry creates a middleware that provides automatic retry functionality for handlers.
The middleware offers configurable retry behavior, including:
- Customizable number of retry attempts
- Flexible backoff strategies
- Configurable retry criteria
- Optional timeout propagation
Default behavior:
- 3 retry attempts
- No delay between attempts
- Retries on any error
- Timeout propagation enabled
Example usage:
flow.Use(Retry("api-retry", retry.WithAttempts(5), retry.WithBackoff(retry.DefaultBackoff(time.Second)), retry.WithRetryCriteria(func(err error) bool { return errors.Is(err, io.ErrTemporary) }), ))
The middleware will stop retrying if:
- An attempt succeeds
- Maximum attempts are reached
- Retry criteria returns false
- Context is canceled (if timeout propagation is enabled)
Types ¶
type LoggingOption ¶ added in v0.0.6
type LoggingOption func(*LoggingOptions)
LoggingOption defines a configuration function for logging middleware.
func WithLogLevels ¶ added in v0.0.6
func WithLogLevels(entry, exit, errorLevel slog.Level) LoggingOption
WithLogLevels sets custom log levels for different events.
func WithLogMessages ¶ added in v0.0.6
func WithLogMessages(enabled bool) LoggingOption
WithLogMessages configures message logging.
func WithLogMetadata ¶ added in v0.0.6
func WithLogMetadata(enabled bool) LoggingOption
WithLogMetadata configures metadata logging.
func WithLogger ¶ added in v0.0.6
func WithLogger(logger *slog.Logger) LoggingOption
WithLogger sets a custom logger.
type LoggingOptions ¶ added in v0.0.6
type LoggingOptions struct { Logger *slog.Logger LogMessages bool LogMetadata bool LogLevels LogLevels }
LoggingOptions defines configuration for logging middleware.
func NewLoggingOptions ¶ added in v0.0.6
func NewLoggingOptions() *LoggingOptions
NewLoggingOptions creates default logging configuration.