contracts

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClientDisconnect

func IsClientDisconnect(err error) bool

IsClientDisconnect checks if error is a client disconnect

func IsConnectionClosed

func IsConnectionClosed(err error) bool

IsConnectionClosed checks if error indicates closed connection

func IsExpectedError

func IsExpectedError(err error) bool

IsExpectedError checks if error is expected (not a real error)

Types

type ChunkProcessor

type ChunkProcessor interface {
	Process(ctx context.Context, data []byte) ([]byte, error)
	Provider() string
}

ChunkProcessor handles format conversion and business logic

type ConnectionState

type ConnectionState interface {
	IsConnected() bool
	Done() <-chan struct{}
}

ConnectionState tracks client connection status

type StreamError

type StreamError struct {
	Type      StreamErrorType
	Message   string
	Cause     error
	RequestID string
}

StreamError provides structured error handling

func NewClientDisconnectError

func NewClientDisconnectError(requestID string) *StreamError

Error constructors

func NewInternalError

func NewInternalError(requestID, message string, cause error) *StreamError

func NewProviderError

func NewProviderError(requestID, provider string, cause error) *StreamError

func NewStreamCompleteError

func NewStreamCompleteError(requestID string) *StreamError

func (*StreamError) Error

func (e *StreamError) Error() string

func (*StreamError) IsExpected

func (e *StreamError) IsExpected() bool

IsExpected returns true if this error type is expected (client disconnect, etc.)

func (*StreamError) Unwrap

func (e *StreamError) Unwrap() error

type StreamErrorType

type StreamErrorType int

StreamErrorType categorizes different types of streaming errors

const (
	// Expected errors - not logged as errors
	ClientDisconnect StreamErrorType = iota
	StreamComplete

	// Unexpected errors - logged as errors
	ProviderError
	InternalError
)

type StreamHandler

type StreamHandler interface {
	Handle(ctx context.Context, writer StreamWriter) error
}

StreamHandler orchestrates the streaming pipeline

type StreamReader

type StreamReader interface {
	io.Reader
	io.Closer
}

StreamReader provides pure I/O reading interface

type StreamWriter

type StreamWriter interface {
	Write([]byte) error
	Flush() error
	Close() error
}

StreamWriter handles output with flush capabilities

Jump to

Keyboard shortcuts

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