Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer interface { io.ReadWriteSeeker Clear() }
Buffer is the underlying buffer interface for allowing the non-seekable source to become seekable
type MemoryBuffer ¶
type MemoryBuffer struct {
// contains filtered or unexported fields
}
MemoryBuffer Buffer implementation using memory buffer suitable for known size that can be fit inside memory
func NewMemoryBuffer ¶
func NewMemoryBuffer(size int64) *MemoryBuffer
NewMemoryBuffer new memory buffer providing data size
func (*MemoryBuffer) Read ¶
func (r *MemoryBuffer) Read(b []byte) (n int, err error)
Read implements the io.Reader interface.
type SeekStream ¶
type SeekStream struct {
// contains filtered or unexported fields
}
SeekStream allows seeking on non-seekable io.ReadCloser source by buffering read data using memory or temp file.
func New ¶
func New(source io.ReadCloser, buffer Buffer) *SeekStream
New SeekStream proving io.ReadCloser source and buffer interface
func (*SeekStream) Close ¶
func (s *SeekStream) Close() (err error)
Close implements the io.Closer interface.
func (*SeekStream) Len ¶
func (s *SeekStream) Len() int
Len returns the number of bytes of the unread portion of buffer
func (*SeekStream) Read ¶
func (s *SeekStream) Read(p []byte) (n int, err error)
Read implements the io.Reader interface.
func (*SeekStream) Seek ¶
func (s *SeekStream) Seek(offset int64, whence int) (int64, error)
Seek implements the io.Seeker interface.
func (*SeekStream) Size ¶
func (s *SeekStream) Size() int64
Size returns the length of the underlying buffer
type TempFileBuffer ¶
TempFileBuffer Buffer implementation using temp file suitable for unknown or large size that does not fit inside memory
func NewTempFileBuffer ¶
func NewTempFileBuffer(dir, pattern string) (*TempFileBuffer, error)
NewTempFileBuffer new temp file buffer. Using os.CreateTemp that creates a new temporary file in the directory dir. The filename is generated by taking pattern and adding a random string to the end.
func (*TempFileBuffer) Clear ¶
func (b *TempFileBuffer) Clear()
Clear performs cleanup on stream close