streaming

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 9 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

Overview

Package streaming is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDecoder

func RegisterDecoder(contentType string, decoder func(io.ReadCloser) Decoder[Event])

Types

type Decoder

type Decoder[E any] interface {
	Current() E
	Next() bool
	Close() error
	Err() error
}

func NewDecoderSSE

func NewDecoderSSE(res *http.Response) Decoder[Event]

type Event

type Event struct {
	Type string
	Data []byte
}

type GenericStreamHandler

type GenericStreamHandler[T any, TypeIn Event] struct{}

GenericStreamHandler implements StreamHandler for basic streaming responses

func NewGenericStreamHandler

func NewGenericStreamHandler[T any, TypeIn Event]() *GenericStreamHandler[T, Event]

func (*GenericStreamHandler[T, TypeIn]) HandleEvent

func (h *GenericStreamHandler[T, TypeIn]) HandleEvent(event Event) (T, error)

func (*GenericStreamHandler[T, TypeIn]) ShouldContinue

func (h *GenericStreamHandler[T, TypeIn]) ShouldContinue(event Event) bool

type MockDecoder

type MockDecoder[E any] struct {
	// contains filtered or unexported fields
}

MockDecoder is a mock of Decoder interface.

func NewMockDecoder

func NewMockDecoder[E any](ctrl *gomock.Controller) *MockDecoder[E]

NewMockDecoder creates a new mock instance.

func (*MockDecoder[E]) Close

func (m *MockDecoder[E]) Close() error

Close mocks base method.

func (*MockDecoder[E]) Current

func (m *MockDecoder[E]) Current() E

Current mocks base method.

func (*MockDecoder[E]) EXPECT

func (m *MockDecoder[E]) EXPECT() *MockDecoderMockRecorder[E]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDecoder[E]) Err

func (m *MockDecoder[E]) Err() error

Err mocks base method.

func (*MockDecoder[E]) Next

func (m *MockDecoder[E]) Next() bool

Next mocks base method.

type MockDecoderMockRecorder

type MockDecoderMockRecorder[E any] struct {
	// contains filtered or unexported fields
}

MockDecoderMockRecorder is the mock recorder for MockDecoder.

func (*MockDecoderMockRecorder[E]) Close

func (mr *MockDecoderMockRecorder[E]) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockDecoderMockRecorder[E]) Current

func (mr *MockDecoderMockRecorder[E]) Current() *gomock.Call

Current indicates an expected call of Current.

func (*MockDecoderMockRecorder[E]) Err

func (mr *MockDecoderMockRecorder[E]) Err() *gomock.Call

Err indicates an expected call of Err.

func (*MockDecoderMockRecorder[E]) Next

func (mr *MockDecoderMockRecorder[E]) Next() *gomock.Call

Next indicates an expected call of Next.

type MockStreamer

type MockStreamer[E any] struct {
	// contains filtered or unexported fields
}

MockStreamer is a mock of Streamer interface.

func NewMockStreamer

func NewMockStreamer[E any](ctrl *gomock.Controller) *MockStreamer[E]

NewMockStreamer creates a new mock instance.

func (*MockStreamer[E]) Close

func (m *MockStreamer[E]) Close() error

Close mocks base method.

func (*MockStreamer[E]) Current

func (m *MockStreamer[E]) Current() E

Current mocks base method.

func (*MockStreamer[E]) EXPECT

func (m *MockStreamer[E]) EXPECT() *MockStreamerMockRecorder[E]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStreamer[E]) Err

func (m *MockStreamer[E]) Err() error

Err mocks base method.

func (*MockStreamer[E]) Next

func (m *MockStreamer[E]) Next() bool

Next mocks base method.

type MockStreamerMockRecorder

type MockStreamerMockRecorder[E any] struct {
	// contains filtered or unexported fields
}

MockStreamerMockRecorder is the mock recorder for MockStreamer.

func (*MockStreamerMockRecorder[E]) Close

func (mr *MockStreamerMockRecorder[E]) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockStreamerMockRecorder[E]) Current

func (mr *MockStreamerMockRecorder[E]) Current() *gomock.Call

Current indicates an expected call of Current.

func (*MockStreamerMockRecorder[E]) Err

func (mr *MockStreamerMockRecorder[E]) Err() *gomock.Call

Err indicates an expected call of Err.

func (*MockStreamerMockRecorder[E]) Next

func (mr *MockStreamerMockRecorder[E]) Next() *gomock.Call

Next indicates an expected call of Next.

type Stream

type Stream[TypeOut any, TypeIn any] struct {
	// contains filtered or unexported fields
}

Stream provides core streaming functionality that can be reused across providers

func NewStream

func NewStream[TypeOut any, TypeIn any](
	decoder Decoder[TypeIn],
	handler StreamHandler[TypeOut, TypeIn],
) *Stream[TypeOut, TypeIn]

func (*Stream[T, E]) Close

func (s *Stream[T, E]) Close() error

func (*Stream[T, E]) Current

func (s *Stream[T, E]) Current() T

func (*Stream[T, E]) Err

func (s *Stream[T, E]) Err() error

func (*Stream[T, E]) Next

func (s *Stream[T, E]) Next() bool

type StreamHandler

type StreamHandler[TypeOut any, TypeIn any] interface {
	HandleEvent(TypeIn) (TypeOut, error)
	ShouldContinue(TypeIn) bool
}

StreamHandler defines the interface for provider-specific stream handling

type Streamer

type Streamer[E any] Decoder[E]

A Streamer is same as decoder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL