Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ERR_INVALID_TIMEOUT = errors.New("Timeout can't below to 0") ERR_MISSING_WORK_FN = errors.New("WorkFn can't be empty") ERR_MISSING_CACHE_KEY = errors.New("Key can't be empty if Cache exists") ERR_MISSING_SF_KEY = errors.New("Key can't be empty if Singleflight exists") ERR_MISSING_BREAKER_FN = errors.New("Breaker can't be empty if BreakerFn exists") ERR_PANIC_RECOVER = errors.New("panic and recover") ERR_TIMEOUT = errors.New("timeout") )
Errors.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.0
type Config struct {
// Key represents keyName of this session
// and mandatory if using Cache / Singleflight
// else optional.
Key string
// Timeout define the amount of time
// for WorkFn to finish the task.
Timeout time.Duration
// WorkFn is function that will be run.
WorkFn func() (interface{}, error)
// Cache store data in memory
// in a way depending on their method.
Cache cache.Cache
// Singleflight make duplicate caller
// flight in one execution.
Singleflight singleflight.Singleflight
// Breaker do go/no-go call to WorkFn
// under certain threshold.
Breaker breaker.Breaker
// SuccessFn runs if WorkFn got success.
SuccessFn func()
// FailFn runs if WorkFn got fail.
FailFn func()
// TimeoutFn runs if WorkFn got timeout.
TimeoutFn func()
// BreakerFn runs if IsErrBerakerOpen=true.
BreakerFn func()
}
Config provides configuration to execute the work function. Only "WorkFn" and "Timeout" is mandatory else is optional. Some optional required some validation.
Opt: "Cache", "Singleflight", "Breaker", "FailFn", "TimeoutFn", "BreakerFn".
Click to show internal directories.
Click to hide internal directories.