archiver

package
v0.0.0-...-678bb0e Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package archiver implements the pipeline to efficiently archive file sets to an isolated server as fast as possible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archiver

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

Archiver is an high level interface to an isolatedclient.Client.

Uses a 4 stages pipeline, each doing work concurrently:

  • Deduplicating similar requests or known server hot cache hits.
  • Hashing files.
  • Batched cache hit lookups on the server.
  • Uploading cache misses.

func New

New returns a thread-safe Archiver instance.

If not nil, out will contain tty-oriented progress information.

ctx will be used for logging.

func (*Archiver) Cancel

func (a *Archiver) Cancel(reason error)

Cancel implements common.Canceler

func (*Archiver) CancelationReason

func (a *Archiver) CancelationReason() error

CancelationReason implements common.Canceler

func (*Archiver) Channel

func (a *Archiver) Channel() <-chan error

Channel implements common.Canceler

func (*Archiver) Close

func (a *Archiver) Close() error

Close waits for all pending files to be done. If an error occured during processing, it is returned.

func (*Archiver) Push

func (a *Archiver) Push(displayName string, source isolatedclient.Source, priority int64) *Item

Push schedules item upload to the isolate server. Smaller priority value means earlier processing.

func (*Archiver) PushFile

func (a *Archiver) PushFile(displayName, path string, priority int64) *Item

PushFile schedules file upload to the isolate server. Smaller priority value means earlier processing.

func (*Archiver) Stats

func (a *Archiver) Stats() *Stats

Stats returns a copy of the statistics.

type Item

type Item struct {
	// Immutable.
	DisplayName string // Name to use to qualify this item
	// contains filtered or unexported fields
}

Item is an item to process.

It is caried over from pipeline stage to stage to do processing on it.

func PushDirectory

func PushDirectory(a *Archiver, root string, relDir string, blacklist []string) *Item

PushDirectory walks a directory at root and creates a .isolated file.

It walks the directories synchronously, then returns a *Item to signal when the background work is completed. The Item is signaled once all files are hashed. In particular, the *Item is signaled before server side cache lookups and upload is completed. Use archiver.Close() to wait for completion.

relDir is a relative directory to offset relative paths against in the generated .isolated file.

blacklist is a list of globs of files to ignore.

func (*Item) Digest

func (i *Item) Digest() isolated.HexDigest

Digest returns the calculated digest once calculated, empty otherwise.

func (*Item) Error

func (i *Item) Error() error

Error returns any error that occurred for this item if any.

func (*Item) SetErr

func (i *Item) SetErr(err error)

SetErr forcibly set an item as failed. Normally not used by callers.

func (*Item) WaitForHashed

func (i *Item) WaitForHashed()

WaitForHashed hangs until the item hash is known.

type Stats

type Stats struct {
	Hits   []units.Size  // Bytes; each item is immutable.
	Pushed []*UploadStat // Misses; each item is immutable.
}

Stats is statistics from the Archiver.

func (*Stats) TotalBytesHits

func (s *Stats) TotalBytesHits() units.Size

TotalBytesHits is the number of bytes not uploaded due to cache hits on the server.

func (*Stats) TotalBytesPushed

func (s *Stats) TotalBytesPushed() units.Size

TotalBytesPushed returns the sum of bytes uploaded.

func (*Stats) TotalHits

func (s *Stats) TotalHits() int

TotalHits is the number of cache hits on the server.

func (*Stats) TotalMisses

func (s *Stats) TotalMisses() int

TotalMisses returns the number of cache misses on the server.

type UploadStat

type UploadStat struct {
	Duration time.Duration
	Size     units.Size
	Name     string
}

UploadStat is the statistic for a single upload.

Jump to

Keyboard shortcuts

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