iobuf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BitBlock = 1 << 15

Variables

This section is empty.

Functions

func AsyncReadCloser

func AsyncReadCloser(proxy ProxyCallback) io.ReadCloser

AsyncReadCloser creates an asynchronous io.ReadCloser that invokes a ProxyCallback to process data in the background.

func BreakInBitmap

func BreakInBitmap(start, end int64, partSize int64) bitmap.Bitmap

func BufBlock

func BufBlock(blocks []uint32) (offset, limit int64)

func ChunkPart

func ChunkPart(blocks []uint32, partSize uint32) (offset, limit int64)

func ChunkWriterCloser

func ChunkWriterCloser(file io.ReadWriteCloser, closer func() error) io.WriteCloser

func CopyWithRateLimit

func CopyWithRateLimit(dst io.Writer, src io.Reader, limiter *rate.Limiter) error

func FullHit

func FullHit(first, last uint32, fs bitmap.Bitmap) bool

func LimitReadCloser

func LimitReadCloser(readCloser io.ReadCloser, max int64) io.ReadCloser

LimitReadCloser wraps an io.ReadCloser, limiting the number of bytes that can be read from it up to a specified maximum.

func NewRateLimitReader

func NewRateLimitReader(r io.ReadCloser, Kbps int) io.ReadCloser

func PartHit

func PartHit(first, last uint32, fs bitmap.Bitmap) bool

func PartsReadCloser

func PartsReadCloser(closer io.Closer, readers ...io.ReadCloser) io.ReadCloser

PartsReadCloser combines multiple io.ReadCloser instances into a single io.ReadCloser, with optional final cleanup logic.

func RangeReader

func RangeReader(r io.ReadCloser, newStart int, newEnd int, rawStart int, rawEnd int) io.ReadCloser

RangeReader returns a ReadCloser that reads a specified byte range from an underlying ReadCloser.

func SavepartAsyncReader

func SavepartAsyncReader(r io.ReadCloser, blockSize uint64, startAt uint,
	flushBuffer EventSuccess, flushFailed EventError, cleanup EventClose,
	writeQueueSize int) io.ReadCloser

SavepartAsyncReader creates an async version that decouples disk I/O from read path

func SavepartReader

func SavepartReader(r io.ReadCloser, blockSize uint64, startAt uint,
	flushBuffer EventSuccess, flushFailed EventError, cleanup EventClose) io.ReadCloser

SavepartReader wraps an io.ReadCloser and allows controlled, buffered reading with custom event handling for specific cases. Parameters: - r: Source io.ReadCloser to read data from. - blockSize: Size of each data block to buffer before triggering an event. - startAt: Initial offset in bytes to start reading from. - flushBuffer: Callback triggered when a block is successfully written. - flushFailed: Callback triggered if an error occurs during block processing. - cleanup: Callback executed when the reader is closed.

func SeekReadCloser

func SeekReadCloser(R io.ReadSeekCloser, offset int64) io.ReadCloser

SeekReadCloser creates an io.ReadCloser that begins reading from the specified offset in the provided io.ReadSeekCloser.

func SkipReadCloser

func SkipReadCloser(R io.ReadCloser, skip int64) io.ReadCloser

Types

type AllCloser

type AllCloser []io.ReadCloser

func (AllCloser) Close

func (rc AllCloser) Close() error

type Block

type Block struct {
	Match      bool     // true: hit, false: miss
	BlockRange []uint32 // [first, ..., last]
}

func BlockGroup

func BlockGroup(hitter bitmap.Bitmap, want bitmap.Bitmap) []*Block

type EventClose

type EventClose func(eof bool)

EventSuccess defines a callback for successful events with data buffer, bit index, position, and EOF flag as parameters. EventError defines a callback to handle errors passed as an argument. EventClose defines a callback invoked when the process is closed, providing an EOF flag.

type EventError

type EventError func(err error)

EventSuccess defines a callback for successful events with data buffer, bit index, position, and EOF flag as parameters. EventError defines a callback to handle errors passed as an argument. EventClose defines a callback invoked when the process is closed, providing an EOF flag.

type EventSuccess

type EventSuccess func(buf []byte, bitIdx uint32, pos uint64, eof bool) error

EventSuccess defines a callback for successful events with data buffer, bit index, position, and EOF flag as parameters. EventError defines a callback to handle errors passed as an argument. EventClose defines a callback invoked when the process is closed, providing an EOF flag.

type ProxyCallback

type ProxyCallback func() (*http.Response, error)

ProxyCallback defines a function type that returns an HTTP response and an error when called.

type RateLimitedWriter

type RateLimitedWriter struct {
	// contains filtered or unexported fields
}

func NewRateLimitedWriter

func NewRateLimitedWriter(w io.Writer, bytesPerSec int) *RateLimitedWriter

func (*RateLimitedWriter) Write

func (rw *RateLimitedWriter) Write(p []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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