go-exit: github.com/simia-tech/go-exit Index | Files | Directories

package exit

import "github.com/simia-tech/go-exit"

Index

Package Files

errors.go exit.go main.go reply.go report.go signal.go

Variables

var (
    ErrTimeout = errors.New("timeout")
)

Defines errors.

var Main = New("main")

Main defines the main exit. This exit should be used by the main program. Libraries should create their own exit.

type Exit Uses

type Exit struct {
    Name string
    // contains filtered or unexported fields
}

Exit defines an exit that contains multiple SignalChans.

func New Uses

func New(name string) *Exit

New returns a new exit with the provided name.

func (*Exit) AfterAll Uses

func (e *Exit) AfterAll(fn func(*Report))

AfterAll registers a callback function that is called after all actors has exited.

func (*Exit) AfterEach Uses

func (e *Exit) AfterEach(fn func(error))

AfterEach registers a callback function that is called after each actor that has exited.

func (*Exit) Exit Uses

func (e *Exit) Exit() *Report

Exit sends an ErrChan through all the previously generated SignalChans and waits until all returned an error or nil. The received errors will be returned in an error report.

func (*Exit) ExitOn Uses

func (e *Exit) ExitOn(osSignales ...os.Signal) *Report

ExitOn blocks until the process receives one of the provided signals and than calls Exit.

func (*Exit) HasTimeout Uses

func (e *Exit) HasTimeout() bool

HasTimeout returns true if a timeout is set.

func (*Exit) NewSignal Uses

func (e *Exit) NewSignal(name string) *Signal

NewSignal creates a new Signal, attaches it to the exit and returns it.

func (*Exit) SetTimeout Uses

func (e *Exit) SetTimeout(value time.Duration)

SetTimeout sets a timeout for the actors to end during the exit process.

type Reply Uses

type Reply chan error

Reply defines a channel of errors that can be used to deliver back an error after an actor has shut down.

func (Reply) Err Uses

func (r Reply) Err(err error)

Err reports back the provided error.

func (Reply) Ok Uses

func (r Reply) Ok()

Ok report back no error. Same as Err(nil).

type Report Uses

type Report struct {
    ExitName string
    // contains filtered or unexported fields
}

Report defines the report of the exit process. It contains map of all signal names with their returned error.

func NewReport Uses

func NewReport(exitName string) *Report

NewReport returns a new initialized Report.

func (*Report) Error Uses

func (r *Report) Error() string

Error implements the error interface.

func (*Report) Get Uses

func (r *Report) Get(name string) error

Get return the error for the provided name.

func (*Report) Len Uses

func (r *Report) Len() int

Len returns the number of errors in the report.

func (*Report) Set Uses

func (r *Report) Set(name string, err error)

Set the provided error for the provided name.

func (*Report) WriteTo Uses

func (r *Report) WriteTo(w io.Writer) (int64, error)

WriteTo prints the report to the provided io.Writer.

type Signal Uses

type Signal struct {
    Name string
    Chan chan Reply
    // contains filtered or unexported fields
}

Signal defines an exit signal signal for a single actor.

func NewSignal Uses

func NewSignal(name string) *Signal

NewSignal returns a new initialized signal with the provided name.

func (*Signal) AfterExit Uses

func (s *Signal) AfterExit(fn func(error))

AfterExit registers a callback function that is called after the exit has been performed.

func (*Signal) Exit Uses

func (s *Signal) Exit() (err error)

Exit performs the exit process for this specific signal.

func (*Signal) HasTimeout Uses

func (s *Signal) HasTimeout() bool

HasTimeout returns true if a timeout is set.

func (*Signal) SetTimeout Uses

func (s *Signal) SetTimeout(value time.Duration)

SetTimeout sets the timeout for this specific exit signal to complete. If no or zero timeout is set, the exit process can last forever.

Directories

PathSynopsis
example

Package exit imports 9 packages (graph) and is imported by 1 packages. Updated 2016-07-23. Refresh now. Tools for package owners.