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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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