task

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: GPL-3.0 Imports: 4 Imported by: 2

README

بِسْمِ اللّٰهِ الرَّحْمٰنِ الرَّحِيْمِ


السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ


ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ


اللَّهُمَّ صَلِّ عَلَى مُحَمَّدٍ ، وَعَلَى آلِ مُحَمَّدٍ ، كَمَا صَلَّيْتَ عَلَى إِبْرَاهِيمَ وَعَلَى آلِ إِبْرَاهِيمَ ، إِنَّكَ حَمِيدٌ مَجِيدٌ ، اللَّهُمَّ بَارِكْ عَلَى مُحَمَّدٍ ، وَعَلَى آلِ مُحَمَّدٍ ، كَمَا بَارَكْتَ عَلَى إِبْرَاهِيمَ ، وَعَلَى آلِ إِبْرَاهِيمَ ، إِنَّكَ حَمِيدٌ مَجِيدٌ

Task

Coverage Status CircleCI Go Report Card

Task is a library to manage and execute tasks.

Documentation

Index

Constants

View Source
const (
	// DefaultBufferSize specifies the default size of channel.
	DefaultBufferSize = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClosureAnonym

type ClosureAnonym func()

ClosureAnonym defines the anonymous function for the Run argument.

type ClosureErr

type ClosureErr func() (err error)

ClosureErr defines closure that returns error.

type ErrorManager

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

ErrorManager contains Manager but especially for error function.

func NewErrorManager

func NewErrorManager(fns ...OptionFunc) *ErrorManager

NewErrorManager initialize the new error manager.

func (*ErrorManager) Assign

func (em *ErrorManager) Assign(fns ...OptionFunc) *ErrorManager

Assign assigns the OptionFunc to the opt in the error manager.

func (*ErrorManager) ErrChan

func (em *ErrorManager) ErrChan() <-chan error

ErrChan returns the receiving error channel of this error manager.

func (*ErrorManager) Error

func (em *ErrorManager) Error() (err error)

Error returns the first error from the Run execution of the fn closure.

func (*ErrorManager) Run

func (em *ErrorManager) Run(fn ClosureErr) *ErrorManager

Run runs the closure error function.

func (*ErrorManager) WaitClose

func (em *ErrorManager) WaitClose() *ErrorManager

WaitClose wait all go routines to complete and close the channel in the separate go routine.

type Manager

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

Manager contains all the required tools to manage the task.

func NewManager

func NewManager(fns ...OptionFunc) *Manager

NewManager initialize the task manager.

func (*Manager) Assign

func (m *Manager) Assign(fns ...OptionFunc) *Manager

Assign assigns the functional option to the opt in the Manager.

func (*Manager) Run

func (m *Manager) Run(fn ClosureAnonym) *Manager

Run runs the task in a separate go function.

func (*Manager) Wait

func (m *Manager) Wait() *Manager

Wait blocks the current thread until the wg counter is zero.

type Option

type Option struct {
	// Not affected by Default() method.
	// UsePanicHandler defaults to false
	UsePanicHandler bool

	// Affected by Default() method.
	// Default is DefaultBufferSize
	BufferSize int
}

Option specifies the option to be used in this package.

func NewDefaultOption

func NewDefaultOption() *Option

NewDefaultOption initialize a new default Option.

func NewOption

func NewOption() *Option

NewOption initialize a new Option.

func (*Option) Assign

func (o *Option) Assign(opts ...OptionFunc) *Option

Assign assign the functional options list to the Option.

func (*Option) Clone

func (o *Option) Clone() *Option

Clone clonse the current option.

func (*Option) Default

func (o *Option) Default() *Option

Default sets the default value of the Option.

type OptionFunc

type OptionFunc func(*Option)

OptionFunc specifies the optional function for this package.

func WithBufferSize

func WithBufferSize(input int) OptionFunc

WithBufferSize sets the buffer size of the error manager.

func WithPanicHandler

func WithPanicHandler(confirm bool) OptionFunc

WithPanicHandler adds the option to toggle the panic handler on and off.

Jump to

Keyboard shortcuts

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