Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MulticastController ¶
type MulticastController struct {
// contains filtered or unexported fields
}
MulticastController 多播控制器,管理源流到多个子流的分发 提供优雅关闭、错误传播、背压控制等生产级特性
func NewMulticastController ¶
func NewMulticastController(source *schema.StreamReader, bufferSize int) *MulticastController
NewMulticastController 创建多播控制器
func (*MulticastController) Fork ¶
func (mc *MulticastController) Fork(n int) []*schema.StreamReader
Fork 创建 N 个子流,返回可独立读取的 StreamReader 列表 子流通过内部缓冲实现背压隔离,慢消费者不会影响其他消费者
func (*MulticastController) Stop ¶
func (mc *MulticastController) Stop()
Stop 停止多播,关闭所有子流 注意:Stop 不会等待转发协程结束,而是立即关闭所有子流
type StreamWriter ¶
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter 流式消息写入器 与 StreamReader 配对使用,用于向流中发送消息
func PipeStreamReader ¶
func PipeStreamReader() (*schema.StreamReader, *StreamWriter)
PipeStreamReader 创建一个配对的 StreamReader 和 StreamWriter 类似于 io.Pipe,但用于 Message 流
func (*StreamWriter) CloseWithError ¶
func (sw *StreamWriter) CloseWithError(err error)
CloseWithError 关闭写入器并设置错误
Click to show internal directories.
Click to hide internal directories.