Documentation ¶
Overview ¶
Package status provides utilities for status and errors.
Index ¶
- func DownstreamError(err error) error
- func DownstreamErrorf(format string, a ...any) error
- func InitSource(ctx context.Context) context.Context
- func IsCancelledError(err error) bool
- func IsDownstreamError(err error) bool
- func IsDownstreamHTTPError(err error) bool
- func WithDownstreamSource(ctx context.Context) error
- func WithSource(ctx context.Context, s Source) error
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownstreamError ¶
DownstreamError creates a new error with status SourceDownstream.
func DownstreamErrorf ¶
DownstreamErrorf creates a new error with status SourceDownstream and formats according to a format specifier and returns the string as a value that satisfies error.
func InitSource ¶
InitSource initialize the source for the context.
func IsCancelledError ¶
InCancelledError returns true if err is context.Canceled or is gRPC status Canceled.
func IsDownstreamError ¶
IsDownstreamError return true if provided error is an error with downstream source or a timeout error or a cancelled error.
func IsDownstreamHTTPError ¶
IsDownstreamHTTPError return true if provided error is an error with downstream source or a HTTP timeout error or a cancelled error or a connection reset/refused error or dns not found error.
func WithDownstreamSource ¶
WithDownstreamSource mutates the provided context by setting the source to SourceDownstream. If the provided context does not have a source, the context will not be mutated and an error returned. This means that InitSource has to be called before this function.
func WithSource ¶
WithSource mutates the provided context by setting the source to s. If the provided context does not have a source, the context will not be mutated and an error returned. This means that InitSource has to be called before this function.
Types ¶
type Source ¶
type Source string
Source type defines the status source.
const ( // SourcePlugin status originates from plugin. SourcePlugin Source = "plugin" // SourceDownstream status originates from downstream service. SourceDownstream Source = "downstream" // DefaultSource is the default [Source] that should be used when it is not explicitly set. DefaultSource Source = SourcePlugin )
func SourceFromContext ¶
SourceFromContext returns the source stored in the context. If no source is stored in the context, DefaultSource is returned.
func SourceFromHTTPStatus ¶
ErrorSourceFromStatus returns a Source based on provided HTTP status code.
func (Source) IsValid ¶
IsValid return true if es is SourceDownstream or SourcePlugin.
func (Source) String ¶
String returns the string representation of s. If s is not valid, DefaultSource is returned.