Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRetryableCategory ¶ added in v0.2.0
func IsRetryableCategory(cat ErrorCategory) bool
IsRetryableCategory returns whether a given error category is worth retrying. Client errors (4xx) are never retried. DNS and TLS errors are generally not retried since they indicate configuration problems. Unexpected status codes are not retried since the server responded -- the issue is a mismatch between the response and the webhook's expected_status_codes.
Types ¶
type ErrorCategory ¶ added in v0.2.0
type ErrorCategory string
ErrorCategory classifies delivery errors for health metrics and retry decisions.
const ( // CategorySuccess indicates no error occurred. CategorySuccess ErrorCategory = "success" // CategoryClientError indicates a 4xx HTTP response. // These are permanent failures that should never be retried // (bad request, unauthorized, forbidden, not found, etc.). CategoryClientError ErrorCategory = "client_error" // CategoryServerError indicates a 5xx HTTP response. // These are temporary server-side failures that should be retried. CategoryServerError ErrorCategory = "server_error" // CategoryTimeout indicates a request or connection timeout. // Retryable - the server may recover. CategoryTimeout ErrorCategory = "timeout" // CategoryDNSError indicates the domain could not be resolved. // Typically persistent - suggests misconfigured webhook URL. CategoryDNSError ErrorCategory = "dns_error" // CategoryTLSError indicates a TLS/SSL handshake failure. // Usually persistent - certificate issues, protocol mismatch, etc. CategoryTLSError ErrorCategory = "tls_error" // CategoryConnectionRefused indicates the target actively refused the connection. // May be temporary (service restarting) or permanent (wrong port). CategoryConnectionRefused ErrorCategory = "connection_refused" // CategoryNetworkError covers other network-level errors: // connection reset, host unreachable, broken pipe, etc. // Typically retryable. CategoryNetworkError ErrorCategory = "network_error" // CategoryUnexpectedStatus indicates the HTTP response code did not match // the webhook's configured expected_status_codes. For example, a 201 response // when only 200 is expected. The server responded, but the status is not // considered successful by the webhook's configuration. // Not retryable - the target responded correctly from its perspective; // the mismatch is a configuration or contract issue. CategoryUnexpectedStatus ErrorCategory = "unexpected_status" // CategoryUnknown is used when the error cannot be classified. CategoryUnknown ErrorCategory = "unknown" )
func ClassifyError ¶ added in v0.2.0
func ClassifyError(err error) ErrorCategory
ClassifyError inspects a Go error from an HTTP request and returns the appropriate error category. It unwraps url.Error, net.OpError, and other standard library error types to determine the root cause.
func ClassifyHTTPStatus ¶ added in v0.2.0
func ClassifyHTTPStatus(statusCode int) ErrorCategory
ClassifyHTTPStatus categorizes an HTTP response status code.