queue

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DataTransfer dataKey used for loading the transfer from the context.
	DataTransfer dataKey = iota
	// PayloadKey to load from the transfer.
	PayloadKey
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Follower

type Follower interface {
	// Start following the Leader.
	Start(context.Context)
	// Stop following the Leader.
	Stop()
}

Follower of the Leader.

func NewFollower

func NewFollower(leader Leader) Follower

NewFollower creates a new Follower instance.

type Job

type Job interface {
	// Payload returns the job's Payload.
	Payload() Payload

	// Workflow returns the job's to be applied Workflow.
	Workflow() Workflow
}

Job definition.

func NewJob

func NewJob(payload Payload, workflow Workflow) Job

NewJob creates a new Job instance.

type Leader

type Leader interface {
	// Run as fast as he can.
	Run(context.Context)
	// Stop the running.
	Stop()
	// AddToFollowersPool an idle follower.
	AddToFollowersPool(chan Job)
	// ReportCompletion by a Follower.
	ReportCompletion()
	// ReportError to the error queue.
	ReportError(error)
	// Wait on the Leader to finish.
	Wait()
}

Leader of one or more Follower.

func NewLeader

func NewLeader(jobsQueue chan Job, errorsQueue chan error, concurrency uint) Leader

NewLeader creates a new Leader instance.

type Payload

type Payload interface{}

Payload of the Job.

type ResultSet

type ResultSet struct {
	URL    string
	Result string
}

ResultSet container for the final result to be displayed.

type Task

type Task interface {
	// Run as fast as it could.
	Run(context.Context) error
}

Task to be applied inside a Workflow.

type Transfer

type Transfer interface {
	// Set the dataKey to be stored in the Transfer.
	Set(dataKey, interface{}) Transfer
	// Get the value from the Transfer.
	Get(dataKey) interface{}
}

Transfer the data between the tasks.

func NewDataTransfer

func NewDataTransfer() Transfer

NewDataTransfer creates a Transfer instance.

type Workflow

type Workflow interface {
	// Execute one or more Task.
	Execute(context.Context) error
}

Workflow to be executed for a job.

func NewWorkflow

func NewWorkflow(tasks ...Task) Workflow

NewWorkflow creates a new Workflow instance.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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