repository

package
v0.0.0-...-0f4c570 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package repository provides common ways to dial reflow.Repository implementations; it also provides some common utilities for working with repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(rawurl string) (reflow.Repository, error)

Dial attempts to connect to the repository named by the given URL. The URL's scheme must be registered with RegisterScheme.

func Marshal

func Marshal(ctx context.Context, repo reflow.Repository, v interface{}) (digest.Digest, error)

Marshal marshals the value v and stores it in the provided repository. The digest of the contents of the marshaled content is returned.

func Missing

func Missing(ctx context.Context, r reflow.Repository, files ...reflow.File) ([]reflow.File, error)

Missing returns the files in files that are missing from repository r. Missing returns an error if any underlying call fails.

func RegisterScheme

func RegisterScheme(scheme string, dial func(*url.URL) (reflow.Repository, error))

RegisterScheme associates a dialler with a URL scheme.

func Transfer

func Transfer(ctx context.Context, dst, src reflow.Repository, id digest.Digest) error

Transfer attempts to transfer an object from one repository to another. It attempts to achieve this via direct transfer, but falling back to copying when necessary.

BUG(marius): Transfer (or the underyling repositories) should ensure that progress is made.

func Unmarshal

func Unmarshal(ctx context.Context, repo reflow.Repository, k digest.Digest, v interface{}) error

Unmarshal unmarshals the value named by digest k into v. If the value does not exist in repository, an error is returned.

func UnregisterScheme

func UnregisterScheme(scheme string)

UnregisterScheme is used for testing.

Types

type Limits

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

Limits stores a default limits and maintains a set of overrides by key.

func NewLimits

func NewLimits(def int) *Limits

NewLimits returns a new Limits with a default value.

func (*Limits) Limit

func (l *Limits) Limit(k string) int

Limit retrieves the limit for key k.

func (*Limits) Set

func (l *Limits) Set(k string, v int)

Set sets limit v for key k.

func (*Limits) String

func (l *Limits) String() string

type Manager

type Manager struct {
	// Log is used to report manager status.
	Log *log.Logger

	// PendingTransfers defines limits for the number of outstanding
	// transfers a repository (keyed by URL) may have in flight.
	// The limit is used separately for transmit and receive traffic.
	// It is not possible currently to set different limits for the two
	// directions.
	PendingTransfers *Limits

	// Stat defines limits for the number of stat operations that
	// may be issued concurrently to any given repository.
	Stat *Limits

	// Status is used to report active transfers to.
	Status *status.Group
	// contains filtered or unexported fields
}

A Manager is used to transfer objects between repositories while enforcing transfer policies.

BUG(marius): Manager does not release references to repositories; in long-term processes, this could cause space leaks.

func (*Manager) NeedTransfer

func (m *Manager) NeedTransfer(ctx context.Context, dst reflow.Repository, files ...reflow.File) ([]reflow.File, error)

NeedTransfer determines which of the provided files are missing from the destination repository and must therefore be transfered.

func (*Manager) Transfer

func (m *Manager) Transfer(ctx context.Context, dst, src reflow.Repository, files ...reflow.File) error

Transfer transmits a set of files between two repositories, subject to policies. Files that already exist in the destination repository are skipped.

TODO(marius): we may want to consider single-flighting download requests by sha. At least for large objects.

Notes

Bugs

  • Manager does not release references to repositories; in long-term processes, this could cause space leaks.

  • Transfer (or the underyling repositories) should ensure that progress is made.

Directories

Path Synopsis
Package client implements repository REST client.
Package client implements repository REST client.
Package file implements a filesystem-backed repository.
Package file implements a filesystem-backed repository.
Package s3 implements an S3-backed repository.
Package s3 implements an S3-backed repository.
Package server implements a Repository REST server.
Package server implements a Repository REST server.

Jump to

Keyboard shortcuts

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