flowctrl

package
v1.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

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

func (*Controller) Reader

func (self *Controller) Reader(underlying io.Reader) io.Reader

func (*Controller) Writer

func (self *Controller) Writer(underlying io.Writer) io.Writer

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL