Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidParams = xerrors.New("parameter invalid")
)
Errors
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is a struct to create and control Limiters.
func NewController ¶
func NewController(interval time.Duration, ticks uint, commonCPS int64, perChildCPS int64) *Controller
NewController creates a new controller instance. interval is a period of time measuring is performed. ticks is a number of gaps interval is divided to. commonCPS is a spped liimit common for all the derrived Limiters. perChildCPS is a default value for each derrived Limiter. Note: each Limiter have 3 limits: it's own one, perChildCPS, and commonCPS. Minimal one is applied in any case. commonCPS is a limit for all the derrived Limiters together.
func (*Controller) BornLimiter ¶
func (c *Controller) BornLimiter() *Limiter
BornLimiter returns a new limiter
func (*Controller) SetCommonCPS ¶
func (c *Controller) SetCommonCPS(cps int64)
SetCommonCPS sets the one for all together limit
func (*Controller) SetPerChildCPS ¶
func (c *Controller) SetPerChildCPS(cps int64)
SetPerChildCPS changes a default limit for the new Limiters and also reset the limit on al the existing Limiters.