Documentation
¶
Index ¶
- type Buffer
- func (b *Buffer) Append(chunk *httpclient.StreamEvent) bool
- func (b *Buffer) At(index int) (*httpclient.StreamEvent, bool)
- func (b *Buffer) Close()
- func (b *Buffer) IsClosed() bool
- func (b *Buffer) LastAppendedAt() time.Time
- func (b *Buffer) Len() int
- func (b *Buffer) Read(index int) (*httpclient.StreamEvent, int, bool, bool)
- func (b *Buffer) Slice() []*httpclient.StreamEvent
- func (b *Buffer) SubscribeFromCurrent() (<-chan struct{}, int, func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a thread-safe buffer for accumulating stream chunks. It serves as the single source of truth for both live streaming preview and final persistence, eliminating duplicate storage.
The buffer supports:
- Append: adding new chunks from the streaming goroutine
- Slice: reading all chunks for final persistence
func (*Buffer) Append ¶
func (b *Buffer) Append(chunk *httpclient.StreamEvent) bool
Append adds a chunk to the buffer. It is safe to call from the streaming goroutine. Returns false if the buffer is closed.
func (*Buffer) At ¶
func (b *Buffer) At(index int) (*httpclient.StreamEvent, bool)
At returns the chunk at index when present.
func (*Buffer) Close ¶
func (b *Buffer) Close()
Close marks the buffer as closed, preventing further appends.
func (*Buffer) LastAppendedAt ¶
LastAppendedAt returns the timestamp of the last successfully appended chunk.
func (*Buffer) Read ¶
func (b *Buffer) Read(index int) (*httpclient.StreamEvent, int, bool, bool)
Read returns the chunk at index when present, along with the next index and whether the buffer was closed at the same instant the read was performed.
func (*Buffer) Slice ¶
func (b *Buffer) Slice() []*httpclient.StreamEvent
Slice returns a copy of all chunks in the buffer.
func (*Buffer) SubscribeFromCurrent ¶
SubscribeFromCurrent registers a subscriber and atomically returns the current buffer length as the replay cutoff for that subscriber.