| 30 | type event []byte |
| 31 | |
| 32 | type EventStream struct { |
| 33 | ctx context.Context |
| 34 | logger slog.Logger |
| 35 | clk quartz.Clock |
| 36 | |
| 37 | pingPayload []byte |
| 38 | |
| 39 | initiated atomic.Bool |
| 40 | initiateOnce sync.Once |
| 41 | |
| 42 | shutdownOnce sync.Once |
| 43 | eventsCh chan event |
| 44 | |
| 45 | // doneCh is closed when the start loop exits. |
| 46 | doneCh chan struct{} |
| 47 | |
| 48 | // tick sends periodic pings to keep the connection alive. |
| 49 | tick *time.Ticker |
| 50 | } |
| 51 | |
| 52 | // NewEventStream creates a new SSE stream, with an optional payload which is used to send pings every [pingInterval]. |
| 53 | func NewEventStream(ctx context.Context, logger slog.Logger, pingPayload []byte, clk quartz.Clock) *EventStream { |
nothing calls this directly
no outgoing calls
no test coverage detected