{"modulePath":"code.cloudfoundry.org/gorouter","version":"v0.0.0-20250429140807-a602bb6a6243","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package fails\n\n## Variables\n\n```go\nvar AttemptedTLSWithNonTLSBackend = ClassifierFunc(func(err error) bool {\n\treturn errors.As(err, \u0026tls.RecordHeaderError{})\n})\n```\n\n```go\nvar ConnectionResetOnRead = ClassifierFunc(func(err error) bool {\n\tvar opErr *net.OpError\n\tif errors.As(err, \u0026opErr) {\n\t\treturn opErr.Err.Error() == \"read: connection reset by peer\"\n\t}\n\treturn false\n})\n```\n\n```go\nvar ContextCancelled = ClassifierFunc(func(err error) bool {\n\treturn errors.Is(err, context.Canceled)\n})\n```\n\n```go\nvar Dial = ClassifierFunc(func(err error) bool {\n\tvar opErr *net.OpError\n\tif errors.As(err, \u0026opErr) {\n\t\treturn opErr.Op == \"dial\"\n\t}\n\treturn false\n})\n```\n\n```go\nvar ExpiredOrNotYetValidCertFailure = ClassifierFunc(func(err error) bool {\n\tvar certErr x509.CertificateInvalidError\n\tif errors.As(err, \u0026certErr) {\n\t\treturn certErr.Reason == x509.Expired\n\t}\n\treturn false\n})\n```\n\n```go\nvar FailableClassifiers = ClassifierGroup{\n\tDial,\n\tAttemptedTLSWithNonTLSBackend,\n\tHostnameMismatch,\n\tRemoteFailedCertCheck,\n\tRemoteHandshakeFailure,\n\tRemoteHandshakeTimeout,\n\tUntrustedCert,\n\tExpiredOrNotYetValidCertFailure,\n\tConnectionResetOnRead,\n}\n```\n\n```go\nvar HostnameMismatch = ClassifierFunc(func(err error) bool {\n\treturn errors.As(err, \u0026x509.HostnameError{})\n})\n```\n\n```go\nvar IdempotentRequestEOF = ClassifierFunc(func(err error) bool {\n\treturn errors.Is(err, IdempotentRequestEOFError)\n})\n```\n\n```go\nvar IdempotentRequestEOFError = errors.New(\"EOF (via idempotent request)\")\n```\n\n```go\nvar IncompleteRequest = ClassifierFunc(func(err error) bool {\n\treturn errors.Is(err, IncompleteRequestError)\n})\n```\n\n```go\nvar IncompleteRequestError = errors.New(\"incomplete request\")\n```\n\n```go\nvar PrunableClassifiers = ClassifierGroup{\n\tDial,\n\tAttemptedTLSWithNonTLSBackend,\n\tHostnameMismatch,\n\tRemoteFailedCertCheck,\n\tRemoteHandshakeFailure,\n\tRemoteHandshakeTimeout,\n\tUntrustedCert,\n\tExpiredOrNotYetValidCertFailure,\n}\n```\n\n```go\nvar RemoteFailedCertCheck = ClassifierFunc(func(err error) bool {\n\tvar opErr *net.OpError\n\tif errors.As(err, \u0026opErr) {\n\t\tif opErr.Op == \"remote error\" {\n\t\t\tif opErr.Err.Error() == \"tls: bad certificate\" ||\n\t\t\t\topErr.Err.Error() == \"tls: unknown certificate authority\" ||\n\t\t\t\topErr.Err.Error() == \"tls: certificate required\" {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n})\n```\n\n```go\nvar RemoteHandshakeFailure = ClassifierFunc(func(err error) bool {\n\tvar opErr *net.OpError\n\tif errors.As(err, \u0026opErr) {\n\t\treturn opErr != nil \u0026\u0026 opErr.Error() == \"remote error: tls: handshake failure\"\n\t}\n\treturn false\n})\n```\n\n```go\nvar RemoteHandshakeTimeout = ClassifierFunc(func(err error) bool {\n\treturn err != nil \u0026\u0026 strings.Contains(err.Error(), \"net/http: TLS handshake timeout\")\n})\n```\n\n```go\nvar RetriableClassifiers = ClassifierGroup{\n\tDial,\n\tAttemptedTLSWithNonTLSBackend,\n\tHostnameMismatch,\n\tRemoteFailedCertCheck,\n\tRemoteHandshakeFailure,\n\tRemoteHandshakeTimeout,\n\tUntrustedCert,\n\tExpiredOrNotYetValidCertFailure,\n\tIdempotentRequestEOF,\n\tIncompleteRequest,\n}\n```\nRetriableClassifiers include backend errors that are safe to retry\n\nBackend errors are only safe to retry if we can be certain that they have occurred before any http request data has been sent from gorouter to the backend application.\n\nOtherwise, there’s risk of a mutating non-idempotent request (e.g. send payment) being silently retried without the client knowing.\n\n```go\nvar UntrustedCert = ClassifierFunc(func(err error) bool {\n\tvar tlsCertError *tls.CertificateVerificationError\n\tswitch {\n\tcase errors.As(err, \u0026x509.UnknownAuthorityError{}), errors.As(err, \u0026tlsCertError):\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n})\n```\n\n## Types\n\n```go\ntype Classifier interface {\n\tClassify(err error) bool\n}\n```\n\n```go\ntype ClassifierFunc func(err error) bool\n```\n\n```go\nfunc (f ClassifierFunc) Classify(err error) bool\n```\n\n```go\ntype ClassifierGroup []Classifier\n```\n\n```go\nfunc (cg ClassifierGroup) Classify(err error) bool\n```\nClassify returns true on errors that are retryable\n\n","path":"code.cloudfoundry.org/gorouter/proxy/fails","name":"fails","synopsis":"","isRedistributable":true}
