Documentation
¶
Index ¶
Constants ¶
View Source
const PREFIX_SF_DELIMITER = ":"
Consts
Variables ¶
View Source
var ( ERR_MISSING_PX_KEY_FOR_CACHE = errors.New("PrefixKey can't be empty if Cache exists") ERR_MISSING_PX_KEY_FOR_SF = errors.New("PrefixKey can't be empty if Singleflight exists") ERR_PANIC_AND_RECOVER = errors.New("panic and recover") ERR_TIMEOUT = errors.New("timeout") ERR_MISSING_WORK_FN = errors.New("workFn can't be empty") )
Errors
Functions ¶
This section is empty.
Types ¶
type Caller ¶ added in v0.2.0
type Caller interface {
// Do runs executable functions base on given Config.
// The key will combine with prefixKey if any.
// CompleteFlow: "GetCache" -> "Singleflight" -> "Breaker" -> "WorkFn" -> "SetCache".
Do(key string, timeout time.Duration, workFn func() (interface{}, error), nextFn NextFn) (resp interface{}, err error)
// contains filtered or unexported methods
}
Caller provides list of caller's functions.
type Config ¶ added in v0.2.0
type Config struct {
// PrefixKey represents prefix key of this session
// and mandatory if using Cache / Singleflight
// else optional.
PrefixKey string
// 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
}
Config provides configuration that will support the workFn.
type NextFn ¶ added in v0.3.0
type NextFn struct {
SuccessFn func() // runs if workFn got success.
FailFn func() // runs if workFn got fail.
TimeoutFn func() // runs if workFn got timeout.
BreakerFn func() // runs if IsErrBerakerOpen=true.
GetCacheFn func() // runs if GetCache got success.
SetCacheFn func() // runs if SetCache got success.
}
NextFn provides list of function that will execute, after done in certain situation.
Click to show internal directories.
Click to hide internal directories.