// Code generated by mdatagen. DO NOT EDIT.

package internal

import (
	"errors"
	"time"
)

// TimeoutConfig a timeout configuration. The timeout applies to individual attempts to send data to the backend.
type TimeoutConfig struct {
	// Timeout defines the timeout for every attempt to send data to the backend. A zero timeout means no timeout.
	Timeout time.Duration `mapstructure:"timeout"`

	// prevent unkeyed literal initialization
	_ struct{}
}

// Validate validates the TimeoutConfig fields according to schema annotations.
// Called by confmap on config resolution. Don't call it explicitly to avoid duplicate errors.
func (c *TimeoutConfig) Validate() error {
	var err error

	if c.Timeout < 0 {
		err = errors.Join(err, errors.New("timeout value must be greater than or equal to 0"))
	}

	return err
}

// NewDefaultTimeoutConfig returns a new TimeoutConfig with its default values applied.
// Prefer this over an empty struct literal so default changes stay in sync automatically.
func NewDefaultTimeoutConfig() TimeoutConfig {
	return TimeoutConfig{
		Timeout: 5 * time.Second,
	}
}
