Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type GInstance
- func (g *GInstance) GetContext() context.Context
- func (g *GInstance) IsRunning() bool
- func (g *GInstance) IsTerminating() bool
- func (g *GInstance) LDebug() *zerolog.Event
- func (g *GInstance) LDebugF(functionName string) *zerolog.Event
- func (g *GInstance) LError() *zerolog.Event
- func (g *GInstance) LErrorF(functionName string) *zerolog.Event
- func (g *GInstance) LEvent(eventType string, eventName string, beforeMsg func(event *zerolog.Event))
- func (g *GInstance) LEventCustom(eventType string, eventName string) *zerolog.Event
- func (g *GInstance) LEventF(eventType string, eventName string, functionName string) *zerolog.Event
- func (g *GInstance) LFatal() *zerolog.Event
- func (g *GInstance) LInfo() *zerolog.Event
- func (g *GInstance) LInfoF(functionName string) *zerolog.Event
- func (g *GInstance) LPanic() *zerolog.Event
- func (g *GInstance) LWarn() *zerolog.Event
- func (g *GInstance) LWarnF(functionName string) *zerolog.Event
- func (g *GInstance) Run() error
- func (g *GInstance) Stop() error
- type ReRunOnRecoverOptions
Constants ¶
View Source
const ErrCodeAlreadyRunning = 100
View Source
const ErrCodeFailedToSetDefaultValuesForConfig = 104
View Source
const ErrCodeOnRunIsNotAFunction = 103
View Source
const ErrCodeReRunOnRecoverMaxNrOfPanicsIsLowerThanOne = 105
View Source
const ErrCodeRunFunctionAlreadyRunning = 106
View Source
const ErrCodeRunTimeIsZero = 101
View Source
const ErrCodeRunTimesIsLowerThanOne = 102
View Source
const ErrCodeStopFunctionAlreadyRunning = 107
Variables ¶
View Source
var ErrAlreadyRunning = define.Err(ErrCodeAlreadyRunning, "already running...")
View Source
var ErrFailedToSetDefaultValuesForConfig = define.Err(ErrCodeFailedToSetDefaultValuesForConfig, "failed to set default values for config")
View Source
var ErrOnRunIsNotAFunction = define.Err(ErrCodeOnRunIsNotAFunction, "'OnRun' if not a function")
View Source
var ErrReRunOnRecoverMaxNrOfPanicsIsLowerThanOne = define.Err(ErrCodeReRunOnRecoverMaxNrOfPanicsIsLowerThanOne, "'rerun on recover max nr of panics' times is lower than -1")
View Source
var ErrRunFunctionAlreadyRunning = define.Err(ErrCodeRunFunctionAlreadyRunning, "Run function already running...")
View Source
var ErrRunTimeIsZero = define.Err(ErrCodeRunTimeIsZero, "'run times' is 0")
View Source
var ErrRunTimesIsLowerThanOne = define.Err(ErrCodeRunTimesIsLowerThanOne, "'run times' is lower than -1")
View Source
var ErrStopFunctionAlreadyRunning = define.Err(ErrCodeStopFunctionAlreadyRunning, "Stop function already running...")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Logger Logger *model.Logger OnRun func(instance *GInstance) // AutoRecover -> from panic! // It's a boolean AutoRecover interface{} `yaml:"auto_recover" mapstructure:"auto_recover" default:"yes"` // If the function OnRun had a panic, and it AutoRecovered, should it rerun itself again?! // If setting no, it will not rerun itself, // If Setting yes, it will rerun itself, // but be very carefully, it can run infinitely if you have infinite panics! // It's a boolean ReRunOnRecover interface{} `yaml:"rerun_on_recover" mapstructure:"rerun_on_recover" default:"no"` // This is the recovery options related to ReRunOnRecover ReRunOnRecoverOptions ReRunOnRecoverOptions `yaml:"rerun_on_recover_options" mapstructure:"rerun_on_recover_options"` // Add how many times it should run! default it's 1, -1 it's infinite, any number of times! RunTimes int `yaml:"run_times" mapstructure:"run_times" default:"1"` // AutoRun -> It's a Boolean, Should it run on creation!? AutoRun interface{} `yaml:"auto_run" mapstructure:"auto_run" default:"yes"` // when the execution finished! OnRunFinished func(instance *GInstance) OnExiting func(instance *GInstance) // OnAllFinished -> when everything has being finished as planned OnAllFinished func(instance *GInstance) }
Config -> options
type GInstance ¶
func (*GInstance) GetContext ¶
func (*GInstance) IsTerminating ¶
IsTerminating -> usually it's necessary for the callback, to know if the goroutines it's being declared to terminate or the parents!
func (*GInstance) LDebugF ¶
LDebugF -> when you need specifically to indicate in what function the logging is happening
func (*GInstance) LErrorF ¶
LErrorF -> when you need specifically to indicate in what function the logging is happening
func (*GInstance) LEventCustom ¶
func (*GInstance) LInfoF ¶
LInfoF -> when you need specifically to indicate in what function the logging is happening
type ReRunOnRecoverOptions ¶
type ReRunOnRecoverOptions struct { // After how much time it should run again after recovery! Duration it's measured in nanoseconds -> 100000000 = 100 ms or 0.1 seconds RunAfterDuration time.Duration `yaml:"run_after_duration" mapstructure:"run_after_duration" default:"100000000"` // How many panics it should be allowed to happen... -1 is infinite! MaxNrOfPanics int `yaml:"max_nr_of_panics" mapstructure:"max_nr_of_panics" default:"-1"` }
Click to show internal directories.
Click to hide internal directories.