exitreason

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Each process should return a valid exitreason.S when it's [Runable.Receive] returns. The specific kind of return will influence how higher order components such as Supervisors and Registries handle process exits.

In the event a process exits unexpectedly (ie. panic), then an Exception reason is returned.

Index

Constants

This section is empty.

Variables

View Source
var (
	// A normal process exit.
	Normal = &S{short: normal}
	// Indicates a process's Supervisor terminated the process. Also considered a "Normal" exit.
	SupervisorShutdown = &S{short: supervisorShutdown}
	// The pid or name does not identifiy an active process
	NoProc = &S{short: noProc}
	// Returned when a request exceeds it's specified timeout.
	Timeout = &S{short: timeout}
	// This is special type of exit reason that would allow a Supervisor to ignore
	// a genserver that doesn't start while keeping it's child specification around
	// so it can be started later.
	Ignore = &S{short: ignore}
	// Untrappable exit signal.
	Kill = &S{short: kill}
	// The process stopped after replying to a Call
	Stopped  = &S{short: stopped}
	TestExit = &S{short: testExit}
)

Sentinel errors

Functions

func Exception

func Exception(reason error) error

General "error" exitreason. Returned when a process panicks or exits with an error.

func IsException

func IsException(e error) bool

Test if [exitReason] is "Exception"

func IsNormal

func IsNormal(e error) bool

Test if [exitReason] is "Normal"

func IsShutdown

func IsShutdown(e error) bool

Test if [exitReason] is "Shutdown"

func Shutdown

func Shutdown(reason any) error

Returned when a process is exiting cleanly. Optionally provide additional info that will be returned to monitors/links. Considered a "Normal" exit.

func Wrap

func Wrap(e error) error

Takes any error and if it is not a *S, then wraps it as an exitreason.Exception

Types

type S

type S struct {
	// contains filtered or unexported fields
}

Opaque return type. Use functions in this package to create new instances and test with the `Is*(exitreason) bool` functions.

For convienence it implements the errors and [stringer] interfaces.

func IsExitReason

func IsExitReason(e error) (err *S)

Tests to see if error is or wraps a *S. If not, returns nil

func To

func To(e error) *S

func (*S) Error

func (s *S) Error() string

func (*S) ExceptionDetail

func (s *S) ExceptionDetail() error

func (*S) ShutdownReason

func (s *S) ShutdownReason() any

Shutdown exitreasons include optional information

func (*S) Unwrap

func (s *S) Unwrap() error

Jump to

Keyboard shortcuts

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