library

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JobDownload represents a Download Job.
	JobDownload = 1 << iota
	// JobUpdate represents an Update Job.
	JobUpdate
)

Variables

View Source
var (
	// ErrNotSivaLibrary is returned when a borges.Library is not a
	//  siva.Library
	ErrNotSivaLibrary = errors.NewKind("not siva library found")

	// ErrNotSivaLocation is returned when a borges.Library is no a
	// siva.Location
	ErrNotSivaLocation = errors.NewKind("not siva location found")
)
View Source
var (
	// ErrJobFnNotFound is returned when theres is no function to
	// process a job.
	ErrJobFnNotFound = errors.NewKind(
		"process function not found for library.Job")
)

Functions

func GetOrgFromEndpoint

func GetOrgFromEndpoint(endpoint string) string

GetOrgFromEndpoint retrieve the organization from an endpoint.

func NewDownloadJobScheduleFn

func NewDownloadJobScheduleFn(
	lib borges.Library,
	download chan gitcollector.Job,
	downloadFn JobFn,
	updateOnDownload bool,
	authTokens map[string]string,
	jobLogger log.Logger,
	temp billy.Filesystem,
) gitcollector.JobScheduleFn

NewDownloadJobScheduleFn builds a new gitcollector.ScheduleFn that only schedules download jobs.

func NewJobScheduleFn

func NewJobScheduleFn(
	lib borges.Library,
	download, update chan gitcollector.Job,
	downloadFn, updateFn JobFn,
	updateOnDownload bool,
	authTokens map[string]string,
	jobLogger log.Logger,
	temp billy.Filesystem,
) gitcollector.JobScheduleFn

NewJobScheduleFn builds a new gitcollector.ScheduleFn that schedules download and update jobs in different queues.

func NewRepositoryID

func NewRepositoryID(endpoint string) (borges.RepositoryID, error)

NewRepositoryID builds a borges.RepositoryID from the given endpoint.

func NewUpdateJobScheduleFn

func NewUpdateJobScheduleFn(
	lib borges.Library,
	update chan gitcollector.Job,
	updateFn JobFn,
	authTokens map[string]string,
	jobLogger log.Logger,
) gitcollector.JobScheduleFn

NewUpdateJobScheduleFn builds a new gitcollector.SchedulerFn that only schedules update jobs.

Types

type AuthTokenFn

type AuthTokenFn func(endpoint string) string

AuthTokenFn retrieve and authentication token if any for the given endpoint.

type Job

type Job struct {
	ID          string
	Type        JobType
	Lib         borges.Library
	TempFS      billy.Filesystem
	LocationID  borges.LocationID
	AllowUpdate bool
	AuthToken   AuthTokenFn
	ProcessFn   JobFn
	Logger      log.Logger
	// contains filtered or unexported fields
}

Job represents a gitcollector.Job to perform a task on a borges.Library.

func (*Job) Endpoints

func (j *Job) Endpoints() []string

func (*Job) Process

func (j *Job) Process(ctx context.Context) error

Process implements the Job interface.

func (*Job) SetEndpoints added in v0.1.0

func (j *Job) SetEndpoints(endpoints []string)

TODO: we should probably secure other fiels

type JobFn

type JobFn func(context.Context, *Job) error

JobFn represents the task to be performed by a Job.

type JobType

type JobType uint8

JobType represents the type of the Job.

Jump to

Keyboard shortcuts

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