repository

package
v0.0.0-...-27a526a Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package repository implements services to work with Git repository storage.

Index

Constants

This section is empty.

Variables

View Source
var ErrCopyCancelled = errors.NewKind("copy was cancelled")

ErrCopyCancelled is returned when a copy is cancelled.

View Source
var HDFSNamenodeError = errors.NewKind("HDFS namenode error")

HDFSNamenodeError is returned when there is a namenode error.

Functions

This section is empty.

Types

type Copier

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

Copier is in charge of copying files from a local filesystem to the remote one and vice-versa. It can optionally bucket files on the remote filesystem.

func NewCopier

func NewCopier(local billy.Filesystem, remote Fs, bucketSize int) *Copier

NewCopier creates a new copier.

func (*Copier) CopyFromRemote

func (c *Copier) CopyFromRemote(ctx context.Context, src, dst string) (err error)

CopyFromRemote copies a file to the local filesystem from the remote one.

func (*Copier) CopyToRemote

func (c *Copier) CopyToRemote(ctx context.Context, src, dst string) error

CopyToRemote copies a file from the local filesystem to the remote one.

func (*Copier) Local

func (c *Copier) Local() billy.Filesystem

Local returns the local filesystem of the copier.

type Fs

type Fs interface {
	// Open a file reader.
	Open(string) (io.ReadCloser, error)
	// WriteTo a file. It returns a file writer.
	WriteTo(string) (io.WriteCloser, error)
	// Rename atomically a file from one path to another.
	Rename(src, dst string) error
	// DeleteIfExists deletes a file only if it exists.
	DeleteIfExists(string) error
	// Base returns the base path of the filesystem to write files to.
	Base() string
}

Fs is a filesystem implementation that has some operations such as opening files, opening file writers, renaming, etc.

func NewHDFSFs

func NewHDFSFs(URL, base string) Fs

NewHDFSFs returns a filesystem that can access a HDFS cluster. URL is the hdfs connection URL and base is the base path to store all the files.

func NewLocalFs

func NewLocalFs(fs billy.Filesystem) Fs

NewLocalFs returns a local file system.

type RootedTransactioner

type RootedTransactioner interface {
	Begin(context.Context, plumbing.Hash) (Tx, error)
}

RootedTransactioner can initiate transactions on rooted repositories.

func NewSivaRootedTransactioner

func NewSivaRootedTransactioner(copier *Copier) RootedTransactioner

NewSivaRootedTransactioner returns a RootedTransactioner for repositories stored in the given billy.Filesystem (using siva file format), and uses a second billy.Filesystem as temporary storage for in-progress transactions.

Note that transactionality is not fully guaranteed by this implementation, since it relies on copying between arbitrary filesystems. If a Commit operation fails, the state of the first filesystem is unknown and can be invalid.

func NewSivaRootedTransactionerWithCache

func NewSivaRootedTransactionerWithCache(
	copier *Copier,
	c cache.Object,
) RootedTransactioner

NewSivaRootedTransactionerWithCache creates a new RootedTransactioner where you can specify its cache.

type Tx

type Tx interface {
	// Storer gets the repository storer. It returns the same instance on
	// every call until Commit or Rollback is performed.
	Storer() storage.Storer
	// Commit commits all changes to the repository.
	Commit(context.Context) error
	// Rollback undoes any changes and cleans up.
	Rollback() error
}

Tx is a transaction on a repository. Any change performed in the given repository storer is in a transaction context. Transactions are guaranteed to be isolated.

Jump to

Keyboard shortcuts

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