Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrAlreadyStarted = errors.New("sse stream already started")
)
Functions ¶
func AsSSEWithHeartbeat ¶
AsSSEWithHeartbeat 带心跳的 SSE
Types ¶
type Event ¶
type Event struct {
Event string `json:"event,omitempty"`
ID string `json:"id,omitempty"`
Data interface{} `json:"data"`
Retry int `json:"retry,omitempty"`
}
Event represents a single SSE event.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a Server-Sent Events stream controller.
func (*Stream) Start ¶
Start marks the stream as started. Returns ErrAlreadyStarted if called more than once.
func (*Stream) StartHeartbeat ¶
StartHeartbeat starts a background goroutine that sends keep-alive comments.