fuse

package
v0.0.0-...-6103407 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Trigger

func Trigger(err error)

Trigger raises an annotated panic in case of an error.

Types

type Error

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

Error encapsulates errors in a synchronized way.

func (*Error) Get

func (e *Error) Get() error

Get retrieves the encapsulated error.

func (*Error) IsNil

func (e *Error) IsNil() bool

IsNil checks is the encapsulated error is nil.

func (*Error) Set

func (e *Error) Set(err error)

Set sets the encapsulated error.

type Reason

type Reason struct {
	Time   time.Time
	Reason interface{}
}

Reason stores time and reason of one recovering.

func (Reason) String

func (r Reason) String() string

String creates a string representation of the reason.

type Reasons

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

Reasons maintains a list of recovery reasons when working with panic recovering. It allows to get statistical information and maintenance of the collected reasons to decide if a recovery makes sense or a loop should be left with an error.

func (*Reasons) Append

func (rs *Reasons) Append(reason interface{})

Append adds a new reason with timestamp to the collection.

func (Reasons) Frequency

func (rs Reasons) Frequency(num int, dur time.Duration) bool

Frequency checks if a given number of panics happened during a given duration.

func (Reasons) Last

func (rs Reasons) Last() Reason

Last returns the last appended reason.

func (Reasons) Len

func (rs Reasons) Len() int

Len returns the length of the recoverings.

func (Reasons) String

func (rs Reasons) String() string

String creates a string representation of the reasons.

func (*Reasons) Trim

func (rs *Reasons) Trim(keep int)

Trim keeps only the defined number of reasons. This way the length can be kept constant.

type Signal

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

Signal allows code to be notified about status changes.

func NewSignal

func NewSignal() *Signal

NewSignal creates a new Signal instance.

func (*Signal) Done

func (s *Signal) Done(status Status) <-chan struct{}

Done implements Signaler.

func (*Signal) Notify

func (s *Signal) Notify(status Status)

Notify sets the new status and informs listeners.

func (*Signal) Status

func (s *Signal) Status() Status

Status implements Signaler.

func (*Signal) Wait

func (s *Signal) Wait(status Status, timeout time.Duration) error

Wait implements Signaler.

type Signaler

type Signaler interface {
	// Status returns the current goroutine status.
	Status() Status

	// Done waits until the given status is notified.
	Done(status Status) <-chan struct{}

	// Wait waits until the given status or duration, what comes first.
	Wait(status Status, timeout time.Duration) error
}

Signaler describes types with a status and able to notify others about its changes. It's the read-only interface to a Signal.

type Status

type Status int

Status describes the status of a background groroutine.

const (
	Unknown Status = iota
	Starting
	Ready
	Working
	Stopping
	Stopped
)

Different statuses of a background goroutine.

func (Status) String

func (s Status) String() string

String implements the fmt.Stringer interface.

Jump to

Keyboard shortcuts

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