remotefile

package
v0.0.0-...-b43479a Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package remotefile defines the protocol-independent remote file read boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadRange

func ReadRange(ctx context.Context, source Source, path string, offset, length int64) ([]byte, error)

Types

type HTTPSource

type HTTPSource struct {
	BaseURL string
	Root    int
	Client  *http.Client
}

HTTPSource adapts another Eta instance's existing read-only API to Source. Peer discovery/configuration remains separate from this transport boundary.

func (*HTTPSource) OpenRange

func (s *HTTPSource) OpenRange(ctx context.Context, path string, offset, length int64) (io.ReadCloser, error)

func (*HTTPSource) Stat

func (s *HTTPSource) Stat(ctx context.Context, path string) (Info, error)

type Info

type Info struct {
	Size     int64
	Modified time.Time
	Version  string
}

func Fetch

func Fetch(ctx context.Context, cache *diskcache.Cache, source Source, path string) ([]byte, Info, error)

Fetch reads a versioned remote file through a cache. It deliberately has no peer protocol dependency: transports implement Source and tests use fakes.

func ReadCachedRange

func ReadCachedRange(ctx context.Context, cache *diskcache.Cache, source Source, path string, offset, length int64) ([]byte, Info, error)

ReadCachedRange reads a bounded byte range and stores it under the file's version. A changed size/mtime produces a new key, so stale blocks are never served after a peer updates a file.

func ReadHotCachedRange

func ReadHotCachedRange(ctx context.Context, hot *rangecache.Cache, cache *diskcache.Cache, source Source, path string, offset, length int64) ([]byte, Info, error)

ReadHotCachedRange checks a deliberately small RAM LRU before disk.

type LocalSource

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

LocalSource is the baseline Source implementation used by a serving Eta host. It provides the same containment boundary a future peer transport must honor.

func NewLocalSource

func NewLocalSource(root string) (*LocalSource, error)

func (*LocalSource) OpenRange

func (s *LocalSource) OpenRange(ctx context.Context, path string, offset, length int64) (io.ReadCloser, error)

func (*LocalSource) Stat

func (s *LocalSource) Stat(_ context.Context, path string) (Info, error)

type Source

type Source interface {
	Stat(context.Context, string) (Info, error)
	OpenRange(context.Context, string, int64, int64) (io.ReadCloser, error)
}

Jump to

Keyboard shortcuts

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