errors

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidToken           = "invalid_token"
	ErrRateLimitExceeded      = "rate_limit_exceeded"
	ErrConnectionLimitReached = "connection_limit_reached"
	ErrServerUnavailable      = "server_unavailable"
	ErrInvalidTunnelInfo      = "invalid_tunnel_info"
	ErrUnknownMessageType     = "unknown_message_type"
	ErrTLSHandshakeFailed     = "tls_handshake_failed"
	ErrAuthenticationFailed   = "authentication_failed"
	ErrTunnelCreationFailed   = "tunnel_creation_failed"
	ErrHeartbeatFailed        = "heartbeat_failed"
)

Error codes as defined in the requirements

Variables

This section is empty.

Functions

This section is empty.

Types

type RelayError

type RelayError struct {
	Code    string        `json:"code"`
	Message string        `json:"message"`
	Retry   bool          `json:"retry,omitempty"`
	Delay   time.Duration `json:"delay,omitempty"`
}

RelayError represents a relay-specific error

func HandleError

func HandleError(err error) (*RelayError, error)

HandleError handles relay-specific errors and returns appropriate actions

func NewRelayError

func NewRelayError(code, message string) *RelayError

NewRelayError creates a new relay error

func (*RelayError) Error

func (e *RelayError) Error() string

Error implements the error interface

func (*RelayError) GetDelay

func (e *RelayError) GetDelay() time.Duration

GetDelay returns the delay before retry

func (*RelayError) IsRetryable

func (e *RelayError) IsRetryable() bool

IsRetryable returns true if the error can be retried

type RetryStrategy

type RetryStrategy struct {
	MaxRetries        int
	BackoffMultiplier float64
	MaxBackoff        time.Duration
	CurrentRetry      int
}

RetryStrategy defines retry behavior

func NewRetryStrategy

func NewRetryStrategy(maxRetries int, backoffMultiplier float64, maxBackoff time.Duration) *RetryStrategy

NewRetryStrategy creates a new retry strategy

func (*RetryStrategy) GetNextDelay

func (rs *RetryStrategy) GetNextDelay(err error) time.Duration

GetNextDelay calculates the delay for the next retry

func (*RetryStrategy) Reset

func (rs *RetryStrategy) Reset()

Reset resets the retry counter

func (*RetryStrategy) ShouldRetry

func (rs *RetryStrategy) ShouldRetry(err error) bool

ShouldRetry determines if an operation should be retried

Jump to

Keyboard shortcuts

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