job

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	// JobType is to select operation type that will be applied to repository
	JobType Type
	// Repository points to the repository that will be used for operation
	Repository *git.Repository
	// Options is a placeholder for operation options
	Options interface{}
}

Job relates the type of the operation and the entity

type Queue

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

Queue holds the slice of Jobs

func CreateJobQueue

func CreateJobQueue() (jq *Queue)

CreateJobQueue creates a jobqueue struct and initialize its slice then return its pointer

func (*Queue) AddJob

func (jq *Queue) AddJob(j *Job) error

AddJob adds a job to the queue

func (*Queue) IsInTheQueue

func (jq *Queue) IsInTheQueue(r *git.Repository) (inTheQueue bool, j *Job)

IsInTheQueue function; since the job and entity is not tied with its own struct, this function returns true if that entity is in the queue along with the jobs type

func (*Queue) RemoveFromQueue

func (jq *Queue) RemoveFromQueue(r *git.Repository) error

RemoveFromQueue deletes the given entity and its job from the queue TODO: it is not safe if the job has been started

func (*Queue) StartJobsAsync

func (jq *Queue) StartJobsAsync() map[*Job]error

StartJobsAsync start he jobs in the queue asynchronously

func (*Queue) StartNext

func (jq *Queue) StartNext() (j *Job, finished bool, err error)

StartNext starts the next job in the queue

type Type

type Type string

Type is the a git operation supported

const (
	// FetchJob is wrapper of git fetch command
	FetchJob Type = "fetch"

	// PullJob is wrapper of git pull command
	PullJob Type = "pull"

	// MergeJob is wrapper of git merge command
	MergeJob Type = "merge"

	// CheckoutJob is wrapper of git merge command
	CheckoutJob Type = "checkout"
)

Jump to

Keyboard shortcuts

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