stream

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackpressureInterceptor

type BackpressureInterceptor struct {
	// contains filtered or unexported fields
}

BackpressureInterceptor 流式RPC的背压控制拦截器

func NewBackpressureInterceptor

func NewBackpressureInterceptor(opts BackpressureOptions) *BackpressureInterceptor

NewBackpressureInterceptor 创建一个新的背压控制拦截器

func (*BackpressureInterceptor) StreamClientInterceptor

func (b *BackpressureInterceptor) StreamClientInterceptor() grpc.StreamClientInterceptor

StreamClientInterceptor 返回客户端流拦截器

func (*BackpressureInterceptor) StreamServerInterceptor

func (b *BackpressureInterceptor) StreamServerInterceptor() grpc.StreamServerInterceptor

StreamServerInterceptor 返回服务端流拦截器

type BackpressureOptions

type BackpressureOptions struct {
	// 最大缓冲区大小(消息数量)
	MaxBufferSize int
	// 高水位线百分比,当缓冲区使用率超过此值时开始限流
	HighWatermarkPct float64
	// 低水位线百分比,当缓冲区使用率低于此值时恢复正常处理
	LowWatermarkPct float64
	// 缓冲区满时的等待超时
	WaitTimeout time.Duration
	// 背压生效时的节流因子 (0-1),表示放行的概率
	ThrottleFactor float64
	// 是否在缓冲区满时阻塞而不是返回错误
	BlockOnFull bool
}

BackpressureOptions 背压控制选项

func DefaultBackpressureOptions

func DefaultBackpressureOptions() BackpressureOptions

DefaultBackpressureOptions 返回默认的背压选项

Jump to

Keyboard shortcuts

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