libraries

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLibraryExists an error returned when a borges.Library
	// added before is attempted to be added again.
	ErrLibraryExists = errors.NewKind("library %s already exists")
)

Functions

func MergeLibraryIterators

func MergeLibraryIterators(iters []borges.LibraryIterator) borges.LibraryIterator

MergeLibraryIterators builds a new iterator from the given ones.

func MergeLocationIterators

func MergeLocationIterators(iters []borges.LocationIterator) borges.LocationIterator

MergeLocationIterators builds a new iterator from the given ones.

func MergeRepositoryIterators

func MergeRepositoryIterators(iters []borges.RepositoryIterator) borges.RepositoryIterator

MergeRepositoryIterators builds a new iterator from the given ones. The merged iterator will keep the order of the given slice of iterators to iterate them.

func RepoIterJumpLibraries

func RepoIterJumpLibraries(
	libs *Libraries,
	mode borges.Mode,
) (borges.RepositoryIterator, error)

RepoIterJumpLibraries returns a borges.RepositoryIterator whose order will be a returned borges.Repository from a different library each time, that is: repo from lib1, repo from lib2, repo from lib3, repo from lib1 ...

func RepoIterJumpLocations

func RepoIterJumpLocations(
	libs *Libraries,
	mode borges.Mode,
) (borges.RepositoryIterator, error)

RepoIterJumpLocations returns a borges.RepositoryIterator whose order will be all the repositories from a location from a different library each time, that is: repos from loc1/lib1, repos from loc1/lib2, repos from loc2/lib1, ...

func RepoIterJumpPlainLibraries

func RepoIterJumpPlainLibraries(
	libs *Libraries,
	mode borges.Mode,
) (borges.RepositoryIterator, error)

RepoIterJumpPlainLibraries returns a borges.RepositoryIterator with the same properties as the one returned by RepoIterJumpLibraries but using only those libraries of type plain.Library.

func RepoIterJumpSivaLocations

func RepoIterJumpSivaLocations(
	libs *Libraries,
	mode borges.Mode,
) (borges.RepositoryIterator, error)

RepoIterJumpSivaLocations returns a borges.RepositoryIterator with the same properties as the one returned by RepoIterJumpLocations but using only those libraries of type siva.Library.

func RepositoryDefaultIter

func RepositoryDefaultIter(
	l *Libraries,
	mode borges.Mode) (borges.RepositoryIterator, error)

RepositoryDefaultIter returns a borges.RepositoryIterator with no specific iteration order.

Types

type FilterLibraryFunc

type FilterLibraryFunc func(borges.Library) (bool, error)

FilterLibraryFunc stands for a borges.Library filter function.

type Libraries

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

Libraries is an implementation to aggregate borges.Library in just one instance. The borges.Library that will be added shouldn't contain other libraries inside.

func New

func New(options *Options) *Libraries

New create a new Libraries instance.

func (*Libraries) Add

func (l *Libraries) Add(lib borges.Library) error

Add adds a new borges.Library. It will fail with ErrLibraryExists if the library was already added.

func (*Libraries) FilteredLibraries

func (l *Libraries) FilteredLibraries(filter FilterLibraryFunc) (borges.LibraryIterator, error)

FilteredLibraries returns an iterator containing only those libraries accomplishing with the FilteredLibraryFunc function.

func (*Libraries) Get

func (l *Libraries) Get(id borges.RepositoryID, mode borges.Mode) (borges.Repository, error)

Get implements the Library interface.

func (*Libraries) GetOrInit

func (l *Libraries) GetOrInit(borges.RepositoryID) (borges.Repository, error)

GetOrInit implements the Library interface.

func (*Libraries) Has

func (l *Libraries) Has(id borges.RepositoryID) (bool, borges.LibraryID, borges.LocationID, error)

Has implements the Library interface.

func (*Libraries) ID

func (l *Libraries) ID() borges.LibraryID

ID implements the Library interface.

func (*Libraries) Init

func (l *Libraries) Init(borges.RepositoryID) (borges.Repository, error)

Init implements the Library interface.

func (*Libraries) Libraries

func (l *Libraries) Libraries() (borges.LibraryIterator, error)

Libraries implements the Library interface.

func (*Libraries) Library

func (l *Libraries) Library(id borges.LibraryID) (borges.Library, error)

Library implements the Library interface.

func (*Libraries) Location

func (l *Libraries) Location(id borges.LocationID) (borges.Location, error)

Location implements the Library interface.

func (*Libraries) Locations

func (l *Libraries) Locations() (borges.LocationIterator, error)

Locations implements the Library interface.

func (*Libraries) Repositories

func (l *Libraries) Repositories(mode borges.Mode) (borges.RepositoryIterator, error)

Repositories implements the Library interface.

type Options

type Options struct {
	// Timeout set a timeout for library operations. Some operations could
	// potentially take long so timing out them will make an error be
	// returned. A 0 value sets a default value of 60 seconds.
	Timeout             time.Duration
	RepositoryIterOrder RepositoryIterFunc
}

Options hold configuration options for a Libraries.

type RepositoryIterFunc

type RepositoryIterFunc func(*Libraries, borges.Mode) (borges.RepositoryIterator, error)

RepositoryIterFunc stands for a function returning a borges.RepositoryIterator which iters in a certain order.

Jump to

Keyboard shortcuts

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