Help us shape the future of Go! Take the 2026 Go Developer Survey

upload

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package upload is the upload file: objects a client sends a store in one piece, each after the ones among them it references. A Writer writes one, a Reader reads it back, and Ingest stores what it holds.

Index

Constants

View Source
const MaxObject = 32 << 20

MaxObject is the largest object an upload file holds.

Variables

View Source
var ErrInvalid = errors.New("invalid upload file")

ErrInvalid is an upload file that can't be read.

Functions

This section is empty.

Types

type Ingested

type Ingested struct {
	Objects, Stored int64
}

Ingested is what Ingest did: the objects the file held, and how many of them the store didn't hold already.

func Ingest

func Ingest(ctx context.Context, r io.Reader, size int64, b backup.Batcher) (Ingested, error)

Ingest stores the objects of the upload file r in b, a batch at a time, skipping those b holds already, so ingesting a file twice stores it once. It asks b about at most 4,096 refs at once. It reports its progress as progress.OpIngest, bytes counting the file's bytes against size.

type Reader

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

Reader reads an upload file.

func NewReader

func NewReader(r io.Reader) (*Reader, error)

NewReader starts reading the upload file r.

func (*Reader) Next

func (r *Reader) Next() (*proto.Object, error)

Next returns the next object, or io.EOF after the last.

func (*Reader) Read

func (r *Reader) Read() int64

Read is how many bytes of the file Next has read.

type Writer

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

Writer writes an upload file: each object as a varint of its length and its bytes.

func NewWriter

func NewWriter(w io.Writer) (*Writer, error)

NewWriter starts an upload file on w.

func (*Writer) Len

func (w *Writer) Len() int64

Len is how many bytes the file has so far.

func (*Writer) Write

func (w *Writer) Write(obj *proto.Object) error

Write appends obj, which must come after the objects of the file it references.

Jump to

Keyboard shortcuts

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