Documentation
¶
Overview ¶
Package ratelimit RateLimit Algorithm Based on Token Bucket
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRateReader ¶
func NewRateReader(r io.Reader, ratePerSecond int) io.ReadCloser
func NewRateReaderWithCtrl ¶
func NewRateReaderWithCtrl(r io.Reader, c *Controller) io.Reader
func NewRateWriter ¶
func NewRateWriter(w io.Writer, ratePerSecond int) io.WriteCloser
func NewRateWriterWithCtrl ¶
func NewRateWriterWithCtrl(w io.Writer, c *Controller) io.Writer
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(ratePerSecond int) *Controller
func (*Controller) Close ¶
func (self *Controller) Close() error
Close release token-producing goroutine
func (*Controller) GetRateLimit ¶
func (self *Controller) GetRateLimit() int
type KeyFlowCtrl ¶
type KeyFlowCtrl struct {
// contains filtered or unexported fields
}
func NewKeyFlowCtrl ¶
func NewKeyFlowCtrl() *KeyFlowCtrl
func (*KeyFlowCtrl) Acquire ¶
func (k *KeyFlowCtrl) Acquire(key string, rate int) *Controller
func (*KeyFlowCtrl) Release ¶
func (k *KeyFlowCtrl) Release(key string)
Click to show internal directories.
Click to hide internal directories.