sse_util

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DONE_MSG = "data: [DONE]\n"

Variables

This section is empty.

Functions

This section is empty.

Types

type SSEWriter

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

SSEWriter 设计sse writer 目标可以规范化统一标准输出方法(所有sse 返回都能用),同时与业务尽可能解耦

func NewSSEWriter

func NewSSEWriter(c *gin.Context, label, doneMsg string) *SSEWriter

func (*SSEWriter) WriteLine

func (sw *SSEWriter) WriteLine(lineText string, done bool, streamProcessParams interface{},
	doneProcessor func(*gin.Context, interface{}) error) error

WriteLine 写入一行给客户端

func (*SSEWriter) WriteStream

func (sw *SSEWriter) WriteStream(sseCh <-chan string, streamContextParams interface{},
	lineBuilder func(*gin.Context, string, interface{}) (string, bool, error),
	doneProcessor func(*gin.Context, interface{}) error) error

WriteStream 流式写入,识别channel 循环写入给前端

Jump to

Keyboard shortcuts

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