Documentation ¶
Overview ¶
Package streams contains the interfaces for groq-go streamed responses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultErrorAccumulator ¶
type DefaultErrorAccumulator struct {
Buffer groqerr.ErrorBuffer
}
DefaultErrorAccumulator is a default implementation of ErrorAccumulator
type ErrorAccumulator ¶
type ErrorAccumulator interface { // Write method writes bytes to the error accumulator // // It implements the io.Writer interface. Write(p []byte) error // Bytes method returns the bytes of the error accumulator. Bytes() []byte }
ErrorAccumulator is an interface for a unit that accumulates errors.
func NewErrorAccumulator ¶
func NewErrorAccumulator() ErrorAccumulator
NewErrorAccumulator creates a new error accumulator
type StreamReader ¶
type StreamReader[T any] struct { Reader *bufio.Reader ErrAccumulator ErrorAccumulator Header http.Header // Header is the header of the response. // contains filtered or unexported fields }
StreamReader is a stream reader.
func NewStreamReader ¶
func NewStreamReader[Q any, T Streamer[Q]]( readCloser io.ReadCloser, header map[string][]string, emptyMessagesLimit uint, ) *StreamReader[T]
NewStreamReader creates a new stream reader.
func (*StreamReader[T]) Close ¶
func (stream *StreamReader[T]) Close() error
Close closes the stream.
func (*StreamReader[T]) Recv ¶
func (stream *StreamReader[T]) Recv() (response T, err error)
Recv receives a response from the stream.
func (*StreamReader[T]) UnmarshalError ¶
func (stream *StreamReader[T]) UnmarshalError() (errResp *groqerr.ErrorResponse)
UnmarshalError unmarshals the error response.
Click to show internal directories.
Click to hide internal directories.