Documentation
¶
Overview ¶
Package errno defines framework-level sentinel errors for onexmesh. They are *errorsx.ErrorX values carrying an HTTP status code and a semantic Reason in the PlatformError.SpecificError form. Because errorsx mutators are copy-on-write, callers can safely extend a sentinel with WithMessage / WithMetadata / KV without mutating the shared value.
Index ¶
- Constants
- Variables
- func IsBadRequest(err error) bool
- func IsCircuitOpen(err error) bool
- func IsGatewayTimeout(err error) bool
- func IsInternal(err error) bool
- func IsNotFound(err error) bool
- func IsOverloaded(err error) bool
- func IsPermissionDenied(err error) bool
- func IsRateLimited(err error) bool
- func IsServiceUnavailable(err error) bool
- func IsTimeout(err error) bool
- func IsTooManyRequests(err error) bool
- func IsUnauthenticated(err error) bool
Constants ¶
const ( ReasonCircuitOpen = "ServiceUnavailable.CircuitOpen" ReasonNoInstance = "ServiceUnavailable.NoInstance" ReasonTimeout = "ServiceUnavailable.Timeout" ReasonRateLimited = "ResourceExhausted.RateLimited" ReasonOverloaded = "ServiceUnavailable.Overloaded" ReasonBulkheadFull = "ResourceExhausted.BulkheadFull" ReasonUnauthenticated = "Unauthenticated" ReasonPermissionDenied = "PermissionDenied" )
Semantic Reason strings in the PlatformError.SpecificError form. They are shared constants so the sentinel errors and the Is* classifiers in reason.go cannot drift apart.
Variables ¶
var ( // ErrCircuitOpen indicates the circuit breaker rejected the request because // it is open (or half-open probing failed). ErrCircuitOpen = errorsx.New( http.StatusServiceUnavailable, ReasonCircuitOpen, "Circuit breaker is open.", ) // ErrNoInstance indicates no healthy service instance was found to serve the // request. ErrNoInstance = errorsx.New( http.StatusServiceUnavailable, ReasonNoInstance, "No available service instance.", ) // ErrTimeout indicates the request exceeded its deadline. ErrTimeout = errorsx.New( http.StatusGatewayTimeout, ReasonTimeout, "Request timed out.", ) // ErrRateLimited indicates the request was dropped by a rate limiter. ErrRateLimited = errorsx.New( http.StatusTooManyRequests, ReasonRateLimited, "Rate limit exceeded.", ) // ErrServiceOverloaded indicates the adaptive load shedder dropped the // request because the service is overloaded. ErrServiceOverloaded = errorsx.New( http.StatusServiceUnavailable, ReasonOverloaded, "Service is overloaded.", ) // ErrBulkheadFull indicates the request was rejected because the downstream // bulkhead (concurrency isolator) has no available capacity. ErrBulkheadFull = errorsx.New( http.StatusTooManyRequests, ReasonBulkheadFull, "Downstream bulkhead is full.", ) // ErrUnauthenticated indicates missing or invalid credentials. ErrUnauthenticated = errorsx.New( http.StatusUnauthorized, ReasonUnauthenticated, "Unauthenticated.", ) // ErrPermissionDenied indicates the caller is authenticated but not // authorized for the resource. ErrPermissionDenied = errorsx.New( http.StatusForbidden, ReasonPermissionDenied, "Permission denied.", ) )
var ( // code is the HTTP status code for a single enum value. // // optional int32 code = 51235; E_Code = &file_errno_proto_extTypes[1] )
Extension fields to descriptorpb.EnumValueOptions.
var ( // default_code is the HTTP status code applied to every enum value that does // not set its own code. // // optional int32 default_code = 51234; E_DefaultCode = &file_errno_proto_extTypes[0] )
Extension fields to descriptorpb.EnumOptions.
var File_errno_proto protoreflect.FileDescriptor
Functions ¶
func IsBadRequest ¶
IsBadRequest reports whether err maps to HTTP 400.
func IsCircuitOpen ¶
IsCircuitOpen reports whether err is a circuit-open failure.
func IsGatewayTimeout ¶
IsGatewayTimeout reports whether err maps to HTTP 504.
func IsOverloaded ¶
IsOverloaded reports whether err is an adaptive-shedding overload failure.
func IsPermissionDenied ¶
IsPermissionDenied reports whether err maps to HTTP 403.
func IsRateLimited ¶
IsRateLimited reports whether err is a rate-limit failure.
func IsServiceUnavailable ¶
IsServiceUnavailable reports whether err maps to HTTP 503.
func IsTooManyRequests ¶
IsTooManyRequests reports whether err maps to HTTP 429.
func IsUnauthenticated ¶
IsUnauthenticated reports whether err maps to HTTP 401.
Types ¶
This section is empty.