Documentation
¶
Index ¶
- func CompressSpecForStorage(spec *openapi3.T) ([]byte, error)
- func EstimateSpecMemoryUsage(spec *openapi3.T) int64
- type BufferPool
- type BytePool
- type ChunkedResponseWriter
- type LargeDataHandler
- type MemoryEfficientSpecLoader
- func (mesl *MemoryEfficientSpecLoader) CreateSpecSummary(spec *openapi3.T, originalSize int64) *SpecSummary
- func (mesl *MemoryEfficientSpecLoader) GetMemoryStats() (allocMB, sysMB int64)
- func (mesl *MemoryEfficientSpecLoader) LoadSpecStreaming(ctx context.Context, reader io.Reader) (*openapi3.T, error)
- func (mesl *MemoryEfficientSpecLoader) OptimizeSpec(spec *openapi3.T) error
- type MemoryLimiter
- type SpecSummary
- type StreamProcessor
- func (sp *StreamProcessor) CheckMemory() bool
- func (sp *StreamProcessor) GetBuffer() *bytes.Buffer
- func (sp *StreamProcessor) GetByteSlice() []byte
- func (sp *StreamProcessor) GetChunkSize() int
- func (sp *StreamProcessor) GetMemoryStats() (allocMB, sysMB int64)
- func (sp *StreamProcessor) PutBuffer(buf *bytes.Buffer)
- func (sp *StreamProcessor) PutByteSlice(b []byte)
- type StreamingJSONProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressSpecForStorage ¶
CompressSpecForStorage compresses spec data for storage
func EstimateSpecMemoryUsage ¶
EstimateSpecMemoryUsage estimates the memory usage of a spec
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool manages a pool of reusable bytes.Buffer instances
func (*BufferPool) Get ¶
func (bp *BufferPool) Get() *bytes.Buffer
Get retrieves a buffer from the pool
func (*BufferPool) Put ¶
func (bp *BufferPool) Put(buf *bytes.Buffer)
Put returns a buffer to the pool for reuse
type BytePool ¶
type BytePool struct {
// contains filtered or unexported fields
}
BytePool manages a pool of reusable byte slices for memory efficiency
func NewBytePool ¶
NewBytePool creates a new byte pool with configurable buffer size
type ChunkedResponseWriter ¶
type ChunkedResponseWriter struct {
// contains filtered or unexported fields
}
ChunkedResponseWriter writes responses in chunks to manage memory usage
func NewChunkedResponseWriter ¶
func NewChunkedResponseWriter(writer io.Writer, maxMemoryMB int64) *ChunkedResponseWriter
NewChunkedResponseWriter creates a new chunked response writer
func (*ChunkedResponseWriter) Close ¶
func (crw *ChunkedResponseWriter) Close() error
Close flushes any remaining data and cleans up resources
func (*ChunkedResponseWriter) GetBytesWritten ¶
func (crw *ChunkedResponseWriter) GetBytesWritten() int64
GetBytesWritten returns the total number of bytes written
type LargeDataHandler ¶
type LargeDataHandler struct {
// contains filtered or unexported fields
}
LargeDataHandler provides utilities for handling large API responses
func NewLargeDataHandler ¶
func NewLargeDataHandler(maxMemoryMB int64) *LargeDataHandler
NewLargeDataHandler creates a new large data handler
func (*LargeDataHandler) GetMemoryStats ¶
func (ldh *LargeDataHandler) GetMemoryStats() (allocMB, sysMB int64)
GetMemoryStats returns current memory usage statistics
func (*LargeDataHandler) ProcessInBatches ¶
func (ldh *LargeDataHandler) ProcessInBatches(ctx context.Context, data []interface{}, batchSize int, processor func([]interface{}) error) error
ProcessInBatches processes large datasets in memory-efficient batches
type MemoryEfficientSpecLoader ¶
type MemoryEfficientSpecLoader struct {
// contains filtered or unexported fields
}
MemoryEfficientSpecLoader loads and processes OpenAPI specifications with memory optimization
func NewMemoryEfficientSpecLoader ¶
func NewMemoryEfficientSpecLoader(maxMemoryMB, maxSpecSizeMB int64) *MemoryEfficientSpecLoader
NewMemoryEfficientSpecLoader creates a new memory-efficient spec loader
func (*MemoryEfficientSpecLoader) CreateSpecSummary ¶
func (mesl *MemoryEfficientSpecLoader) CreateSpecSummary(spec *openapi3.T, originalSize int64) *SpecSummary
CreateSpecSummary creates a lightweight summary of an OpenAPI spec
func (*MemoryEfficientSpecLoader) GetMemoryStats ¶
func (mesl *MemoryEfficientSpecLoader) GetMemoryStats() (allocMB, sysMB int64)
GetMemoryStats returns current memory usage statistics
func (*MemoryEfficientSpecLoader) LoadSpecStreaming ¶
func (mesl *MemoryEfficientSpecLoader) LoadSpecStreaming(ctx context.Context, reader io.Reader) (*openapi3.T, error)
LoadSpecStreaming loads an OpenAPI spec from a reader with memory management
func (*MemoryEfficientSpecLoader) OptimizeSpec ¶
func (mesl *MemoryEfficientSpecLoader) OptimizeSpec(spec *openapi3.T) error
OptimizeSpec optimizes a spec by removing unnecessary fields to reduce memory usage
type MemoryLimiter ¶
type MemoryLimiter struct {
// contains filtered or unexported fields
}
MemoryLimiter helps control memory usage for large operations
func NewMemoryLimiter ¶
func NewMemoryLimiter(maxMemoryMB int64) *MemoryLimiter
NewMemoryLimiter creates a new memory limiter
func (*MemoryLimiter) CheckMemoryUsage ¶
func (ml *MemoryLimiter) CheckMemoryUsage() bool
CheckMemoryUsage checks if memory usage is within limits and optionally triggers GC
func (*MemoryLimiter) GetMemoryStats ¶
func (ml *MemoryLimiter) GetMemoryStats() (allocMB, sysMB int64)
GetMemoryStats returns current memory statistics
type SpecSummary ¶
type SpecSummary struct {
Title string `json:"title"`
Version string `json:"version"`
PathCount int `json:"path_count"`
MethodCount int `json:"method_count"`
SizeBytes int64 `json:"size_bytes"`
}
SpecSummary provides a lightweight summary of a spec for memory-efficient storage
type StreamProcessor ¶
type StreamProcessor struct {
// contains filtered or unexported fields
}
StreamProcessor handles streaming processing of large data to minimize memory usage
func NewStreamProcessor ¶
func NewStreamProcessor(maxMemoryMB int64, chunkSize int) *StreamProcessor
NewStreamProcessor creates a new stream processor for memory-efficient processing
func (*StreamProcessor) CheckMemory ¶
func (sp *StreamProcessor) CheckMemory() bool
CheckMemory checks if processing should continue based on memory usage
func (*StreamProcessor) GetBuffer ¶
func (sp *StreamProcessor) GetBuffer() *bytes.Buffer
GetBuffer returns a buffer from the pool
func (*StreamProcessor) GetByteSlice ¶
func (sp *StreamProcessor) GetByteSlice() []byte
GetByteSlice returns a byte slice from the pool
func (*StreamProcessor) GetChunkSize ¶
func (sp *StreamProcessor) GetChunkSize() int
GetChunkSize returns the configured chunk size for streaming operations
func (*StreamProcessor) GetMemoryStats ¶
func (sp *StreamProcessor) GetMemoryStats() (allocMB, sysMB int64)
GetMemoryStats returns current memory usage statistics
func (*StreamProcessor) PutBuffer ¶
func (sp *StreamProcessor) PutBuffer(buf *bytes.Buffer)
PutBuffer returns a buffer to the pool
func (*StreamProcessor) PutByteSlice ¶
func (sp *StreamProcessor) PutByteSlice(b []byte)
PutByteSlice returns a byte slice to the pool
type StreamingJSONProcessor ¶
type StreamingJSONProcessor struct {
// contains filtered or unexported fields
}
StreamingJSONProcessor handles large JSON responses with memory-efficient streaming
func NewStreamingJSONProcessor ¶
func NewStreamingJSONProcessor(maxMemoryMB int64) *StreamingJSONProcessor
NewStreamingJSONProcessor creates a new streaming JSON processor
func (*StreamingJSONProcessor) ProcessLargeJSON ¶
func (sjp *StreamingJSONProcessor) ProcessLargeJSON(ctx context.Context, reader io.Reader, callback func(interface{}) error) error
ProcessLargeJSON processes large JSON data in chunks to avoid memory issues