io

package
v3.2.265 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 6 Imported by: 0

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 CacheWriter added in v3.2.263

type CacheWriter func(data []byte, offset int64) (int, error)

CacheWriter is a function that writes data to cache at a specific offset.

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 and performs cleanup:

  • Signals that no more writes will occur
  • Streams any pending data to the pipe
  • Closes the underlying io.PipeWriter
  • Closes and removes the temporary file
  • Returns any errors encountered (a closed OrderedPipe cannot be reused)

func (*OrderedPipe) HasWrites added in v3.2.263

func (w *OrderedPipe) HasWrites() bool

HasWrites reports whether any WriteAt calls have occurred (excludes initial content).

func (*OrderedPipe) Offset

func (w *OrderedPipe) Offset() int64

Offset returns the current maximum 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. Returns data that has been written to the temp file.

func (*OrderedPipe) WriteAt

func (w *OrderedPipe) WriteAt(buff []byte, offset int64) (n int, err error)

WriteAt writes data to the OrderedPipe at the specified offset. The underlying os.File handles out-of-order writes automatically.

type OrderedPipeOption

type OrderedPipeOption func(*OrderedPipe)

OrderedPipeOption defines a function type for configuring OrderedPipe.

func WithCacheWriter added in v3.2.263

func WithCacheWriter(cacheWriter CacheWriter) OrderedPipeOption

WithCacheWriter sets a callback that writes data to cache on every WriteAt call. This allows real-time cache updates as writes occur, avoiding a separate copy step.

func WithInitialContent added in v3.2.263

func WithInitialContent(reader io.Reader) OrderedPipeOption

WithInitialContent copies existing file content into the OrderedPipe's temp file before any writes occur. This allows partial updates to preserve unmodified data.

func WithLogger

func WithLogger(logger log.Logger) OrderedPipeOption

WithLogger sets a custom logger for OrderedPipe.

Jump to

Keyboard shortcuts

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