Documentation
¶
Overview ¶
Package backpressure provides flow control mechanisms for data forwarding.
Index ¶
- type AdaptiveConfig
- type AdaptiveController
- func (c *AdaptiveController) CheckAndYield() bool
- func (c *AdaptiveController) IsPaused() bool
- func (c *AdaptiveController) Pause()
- func (c *AdaptiveController) Reset()
- func (c *AdaptiveController) Resume()
- func (c *AdaptiveController) SetWatermarks(low, high int)
- func (c *AdaptiveController) Stats() (pauseCount int64, totalPause time.Duration)
- func (c *AdaptiveController) UpdateLevel(level int)
- type Controller
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdaptiveConfig ¶
type AdaptiveConfig struct {
HighWatermark int
LowWatermark int
YieldMin time.Duration
YieldMax time.Duration
}
AdaptiveConfig holds configuration for AdaptiveController.
type AdaptiveController ¶
type AdaptiveController struct {
// contains filtered or unexported fields
}
AdaptiveController provides adaptive backpressure with exponential backoff. Thread-safe for concurrent use.
func NewAdaptiveController ¶
func NewAdaptiveController(cfg AdaptiveConfig) *AdaptiveController
NewAdaptiveController creates a new adaptive backpressure controller.
func (*AdaptiveController) CheckAndYield ¶
func (c *AdaptiveController) CheckAndYield() bool
CheckAndYield checks if paused and yields CPU time with exponential backoff. Returns true if yielding was performed.
func (*AdaptiveController) IsPaused ¶
func (c *AdaptiveController) IsPaused() bool
IsPaused returns whether the flow is paused.
func (*AdaptiveController) Reset ¶
func (c *AdaptiveController) Reset()
Reset resets the backoff to minimum.
func (*AdaptiveController) Resume ¶
func (c *AdaptiveController) Resume()
Resume allows data flow to continue.
func (*AdaptiveController) SetWatermarks ¶
func (c *AdaptiveController) SetWatermarks(low, high int)
SetWatermarks configures the high and low watermark levels.
func (*AdaptiveController) Stats ¶
func (c *AdaptiveController) Stats() (pauseCount int64, totalPause time.Duration)
Stats returns backpressure statistics.
func (*AdaptiveController) UpdateLevel ¶
func (c *AdaptiveController) UpdateLevel(level int)
UpdateLevel updates the current buffer level and manages watermarks.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller manages backpressure for a data flow.
func NewController ¶
func NewController() *Controller
NewController creates a new backpressure controller.
func (*Controller) CheckAndYield ¶
func (c *Controller) CheckAndYield() bool
CheckAndYield checks if paused and yields CPU time if so. Returns true if yielding was performed.
func (*Controller) IsPaused ¶
func (c *Controller) IsPaused() bool
IsPaused returns whether the flow is paused.
func (*Controller) SetWatermarks ¶
func (c *Controller) SetWatermarks(low, high int)
SetWatermarks configures the high and low watermark levels.
func (*Controller) UpdateLevel ¶
func (c *Controller) UpdateLevel(level int)
UpdateLevel updates the current buffer level and manages watermarks.
type Pair ¶
type Pair struct {
A *Controller
B *Controller
}
Pair manages backpressure for bidirectional data flow.
func (*Pair) SignalErrorA ¶
func (p *Pair) SignalErrorA()
SignalErrorA signals an error in direction A, resuming B.
func (*Pair) SignalErrorB ¶
func (p *Pair) SignalErrorB()
SignalErrorB signals an error in direction B, resuming A.