Documentation
¶
Overview ¶
Package io provides I/O utilities for Files.com FUSE mount.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderedPipe ¶
type OrderedPipe struct {
// Out is an io.Reader that returns the data written to the OrderedPipe in the correct order.
Out *io.PipeReader
// contains filtered or unexported fields
}
OrderedPipe provides a wrapper around an io.Pipe that allows out-of-order writes to be read in the correct order from the Out io.PipeReader.
In addition to the Out io.PipeReader, OrderedPipe implements io.ReaderAt to allow reading correctly ordered data at specific offsets. The io.ReaderAt implementation only supports reading data that has already been sorted, returning 0 bytes if attempting to read beyond offset of the currently sorted data.
In the Files.com use case, this allows the FUSE file system to read data from the OrderedPipe before an upload is finalized.
func NewOrderedPipe ¶
func NewOrderedPipe(ident string, opts ...OrderedPipeOption) (*OrderedPipe, error)
NewOrderedPipe creates a new OrderedPipe with options.
func (*OrderedPipe) Close ¶
func (w *OrderedPipe) Close() error
Close closes the OrderedPipe, including the underlying io.PipeWriter and temporary file. The temporary file is also removed.
It returns any error encountered during the close operations. A closed OrderedPipe cannot be used again.
func (*OrderedPipe) Offset ¶
func (w *OrderedPipe) Offset() int64
Offset returns the current write offset of the OrderedPipe.
func (*OrderedPipe) ReadAt ¶
func (w *OrderedPipe) ReadAt(buff []byte, offset int64) (n int)
ReadAt reads data from the OrderedPipe at the specified offset. It only supports reading data that has already been written in order. If attempting to read beyond the current write offset, it returns 0 bytes.
type OrderedPipeOption ¶
type OrderedPipeOption func(*OrderedPipe)
OrderedPipeOption defines a function type for configuring OrderedPipe.
func WithLogger ¶
func WithLogger(logger log.Logger) OrderedPipeOption
WithLogger sets a custom logger for OrderedPipe.