Documentation
¶
Overview ¶
Package backpressure 提供通用并发背压机制。
本包用 semaphore 限制同一资源的最大 in-flight 操作数,并可配置等待超时。 Acquire 返回原始业务 context 和 release 函数,等待超时只影响排队过程,不会给 下游业务操作额外加 deadline。
包内事件和快照是机制级模型,业务项目可以在外层 adapter 中把它们映射为自己的 metrics、resilience 事件或治理响应。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Component string
Dependency string
Resource string
Strategy string
Outcome Outcome
Wait time.Duration
InFlight int
MaxInflight int
Err error
}
Event 描述一次限流器状态变化。
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter 提供一个可选等待超时的 in-flight 限流器。
func NewLimiter ¶
NewLimiter 根据最大 in-flight 数和可选等待超时创建限流器。
func NewLimiterWithOptions ¶
type NopObserver ¶
type NopObserver struct{}
NopObserver 忽略所有限流事件。
func (NopObserver) OnBackpressure ¶
func (NopObserver) OnBackpressure(context.Context, Event)
Click to show internal directories.
Click to hide internal directories.