Documentation ¶
Overview ¶
Package processor provides a framework for creating processors.
Index ¶
- Constants
- type Func
- type IProcessor
- type OnFinished
- type Processor
- func (p *Processor[T]) GetCounterCreated() *expvar.Int
- func (p *Processor[T]) GetCounterDone() *expvar.Int
- func (p *Processor[T]) GetCounterFailed() *expvar.Int
- func (p *Processor[T]) GetCounterRunning() *expvar.Int
- func (p *Processor[T]) GetDescription() string
- func (p *Processor[T]) GetLogger() sypl.ISypl
- func (p *Processor[T]) GetName() string
- func (p *Processor[T]) GetOnFinished() OnFinished[T]
- func (p *Processor[T]) GetStatus() *expvar.String
- func (p *Processor[T]) GetType() string
- func (p *Processor[T]) Run(ctx context.Context, t []T) ([]T, error)
- func (p *Processor[T]) SetOnFinished(onFinished OnFinished[T])
Constants ¶
const Type = "processor"
Type of the entity.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶ added in v0.1.0
type Func[T any] func(p IProcessor[T]) IProcessor[T]
Func allows to specify message's options.
func WithOnFinished ¶ added in v0.1.0
func WithOnFinished[T any](onFinished OnFinished[T]) Func[T]
WithOnFinished sets the OnFinished function.
type IProcessor ¶
type IProcessor[In any] interface { shared.IMeta shared.IMetrics // GetOnFinished returns the `OnFinished` function. GetOnFinished() OnFinished[In] // SetOnFinished sets the `OnFinished` function. SetOnFinished(onFinished OnFinished[In]) // Run the transform function. Run(ctx context.Context, in []In) (out []In, err error) }
IProcessor defines what a `Processor` must do.
type OnFinished ¶ added in v0.1.0
type OnFinished[T any] func(ctx context.Context, p IProcessor[T], originalIn []T, processedIn []T)
OnFinished is the function that is called when a processor finishes its execution.
type Processor ¶
type Processor[T any] struct { // Description of the processor. Description string `json:"description"` // Transform function. Func shared.Run[T] `json:"-"` // Logger is the pipeline logger. Logger sypl.ISypl `json:"-" validate:"required"` // Name of the processor. Name string `json:"name"` // OnFinished is the function that is called when a processor finishes its // execution. OnFinished OnFinished[T] `json:"-"` // 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"` }
Processor definition.
func (*Processor[T]) GetCounterCreated ¶ added in v0.1.0
GetCounterCreated returns the `CounterCreated` metric.
func (*Processor[T]) GetCounterDone ¶ added in v0.1.0
GetCounterDone returns the `CounterDone` metric.
func (*Processor[T]) GetCounterFailed ¶ added in v0.1.0
GetCounterFailed returns the `CounterFailed` metric.
func (*Processor[T]) GetCounterRunning ¶ added in v0.1.0
GetCounterRunning returns the `CounterRunning` metric.
func (*Processor[T]) GetDescription ¶
GetDescription returns the `Description` of the processor.
func (*Processor[T]) GetOnFinished ¶ added in v0.1.0
func (p *Processor[T]) GetOnFinished() OnFinished[T]
GetOnFinished returns the `OnFinished` function.
func (*Processor[T]) SetOnFinished ¶ added in v0.1.0
func (p *Processor[T]) SetOnFinished(onFinished OnFinished[T])
SetOnFinished sets the `OnFinished` function.