errno

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
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

View Source
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.",
	)
)
View Source
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.

View Source
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.

View Source
var File_errno_proto protoreflect.FileDescriptor

Functions

func IsBadRequest

func IsBadRequest(err error) bool

IsBadRequest reports whether err maps to HTTP 400.

func IsCircuitOpen

func IsCircuitOpen(err error) bool

IsCircuitOpen reports whether err is a circuit-open failure.

func IsGatewayTimeout

func IsGatewayTimeout(err error) bool

IsGatewayTimeout reports whether err maps to HTTP 504.

func IsInternal

func IsInternal(err error) bool

IsInternal reports whether err maps to HTTP 500.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err maps to HTTP 404.

func IsOverloaded

func IsOverloaded(err error) bool

IsOverloaded reports whether err is an adaptive-shedding overload failure.

func IsPermissionDenied

func IsPermissionDenied(err error) bool

IsPermissionDenied reports whether err maps to HTTP 403.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited reports whether err is a rate-limit failure.

func IsServiceUnavailable

func IsServiceUnavailable(err error) bool

IsServiceUnavailable reports whether err maps to HTTP 503.

func IsTimeout

func IsTimeout(err error) bool

IsTimeout reports whether err is a timeout failure.

func IsTooManyRequests

func IsTooManyRequests(err error) bool

IsTooManyRequests reports whether err maps to HTTP 429.

func IsUnauthenticated

func IsUnauthenticated(err error) bool

IsUnauthenticated reports whether err maps to HTTP 401.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL