pipeline

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pipeline provides a framework for creating pipelines.

Index

Constants

View Source
const Type = "pipeline"

Type of the entity.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func added in v0.1.0

type Func[In, Out any] func(p IPipeline[In, Out]) IPipeline[In, Out]

Func allows to specify message's options.

func WithOnFinished added in v0.1.0

func WithOnFinished[In, Out any](onFinished OnFinished[In, Out]) Func[In, Out]

WithOnFinished sets the OnFinished function.

type IPipeline

type IPipeline[In, Out any] interface {
	shared.IMeta

	shared.IMetrics

	// GetPaused returns the Paused status.
	GetPaused() status.Status

	// SetPaused sets the Paused status.
	SetPaused()

	// GetOnFinished returns the `OnFinished` function.
	GetOnFinished() OnFinished[In, Out]

	// SetOnFinished sets the `OnFinished` function.
	SetOnFinished(onFinished OnFinished[In, Out])

	// Run the pipeline.
	Run(ctx context.Context, in []In) (out []Out, err error)
}

IPipeline defines what a `Pipeline` must do.

func New

func New[In, Out any](
	name string,
	description string,
	concurrentStage bool,
	stages ...stage.IStage[In, Out],
) (IPipeline[In, Out], error)

New returns a new pipeline.

type OnFinished added in v0.1.0

type OnFinished[In, Out any] func(ctx context.Context, p IPipeline[In, Out], in []In, processedOut []Out)

OnFinished is the function that is called when a processor finishes its execution.

type Pipeline

type Pipeline[In any, Out any] struct {
	// Concurrent determines whether the stage should be run concurrently.
	ConcurrentStage bool `json:"concurrentStage"`

	// Logger is the pipeline logger.
	Logger sypl.ISypl `json:"-" validate:"required"`

	// Description of the processor.
	Description string `json:"description"`

	// Name of the processor.
	Name string `json:"name" validate:"required"`

	// Progress of the pipeline.
	Progress int `json:"progress"`

	// OnFinished is the function that is called when a processor finishes its
	// execution.
	OnFinished OnFinished[In, Out] `json:"-"`

	// Stages to be used in the pipeline.
	Stages []stage.IStage[In, Out] `json:"stages" validate:"dive,required,dive"`

	// Metrics.
	CounterCreated *expvar.Int    `json:"counterCreated" validate:"required,gte=0"`
	CounterRunning *expvar.Int    `json:"counterRunning" validate:"required,gte=0"`
	CounterFailed  *expvar.Int    `json:"counterFailed" validate:"required,gte=0"`
	CounterDone    *expvar.Int    `json:"counterDone" validate:"required,gte=0"`
	Status         *expvar.String `json:"status" validate:"required,gte=0"`
}

Pipeline definition.

func (*Pipeline[In, Out]) GetCounterCreated added in v0.1.0

func (p *Pipeline[In, Out]) GetCounterCreated() *expvar.Int

GetCounterCreated returns the `CounterCreated` of the processor.

func (*Pipeline[In, Out]) GetCounterDone added in v0.1.0

func (p *Pipeline[In, Out]) GetCounterDone() *expvar.Int

GetCounterDone returns the `CounterDone` of the processor.

func (*Pipeline[In, Out]) GetCounterFailed added in v0.1.0

func (p *Pipeline[In, Out]) GetCounterFailed() *expvar.Int

GetCounterFailed returns the `CounterFailed` of the processor.

func (*Pipeline[In, Out]) GetCounterRunning added in v0.1.0

func (p *Pipeline[In, Out]) GetCounterRunning() *expvar.Int

GetCounterRunning returns the `CounterRunning` of the processor.

func (*Pipeline[In, Out]) GetDescription

func (p *Pipeline[In, Out]) GetDescription() string

GetDescription returns the `Description` of the pipeline.

func (*Pipeline[In, Out]) GetLogger added in v0.1.0

func (p *Pipeline[In, Out]) GetLogger() sypl.ISypl

GetLogger returns the `Logger` of the pipeline.

func (*Pipeline[In, Out]) GetName

func (p *Pipeline[In, Out]) GetName() string

GetName returns the `Name` of the pipeline.

func (*Pipeline[In, Out]) GetOnFinished added in v0.1.0

func (p *Pipeline[In, Out]) GetOnFinished() OnFinished[In, Out]

GetOnFinished returns the `OnFinished` function.

func (*Pipeline[In, Out]) GetPaused added in v0.1.0

func (p *Pipeline[In, Out]) GetPaused() status.Status

GetPaused returns the Paused status.

func (*Pipeline[In, Out]) GetStatus added in v0.1.0

func (p *Pipeline[In, Out]) GetStatus() *expvar.String

GetStatus returns the `Status` metric.

func (*Pipeline[In, Out]) GetType added in v0.1.2

func (p *Pipeline[In, Out]) GetType() string

GetType returns the entity type.

func (*Pipeline[In, Out]) Run

func (p *Pipeline[In, Out]) Run(ctx context.Context, in []In) ([]Out, error)

Run the pipeline.

func (*Pipeline[In, Out]) SetOnFinished added in v0.1.0

func (p *Pipeline[In, Out]) SetOnFinished(onFinished OnFinished[In, Out])

SetOnFinished sets the `OnFinished` function.

func (*Pipeline[In, Out]) SetPaused added in v0.1.0

func (p *Pipeline[In, Out]) SetPaused()

SetPaused sets the Paused status.

Jump to

Keyboard shortcuts

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