processor

package
v0.0.0-...-5bc2b8c Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package processor provides a framework for creating processors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IProcessor

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

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

func New

func New[In any, Out any](
	name string,
	description string,
	fn shared.Run[In, Out],
) IProcessor[In, Out]

New returns a new processor.

type Processor

type Processor[In any, Out any] struct {
	// Name of the processor.
	Name string `json:"name"`

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

	// Transform function.
	Func shared.Run[In, Out] `json:"-"`

	// State of the processor.
	State status.Status `json:"state"`
}

Processor definition.

func (*Processor[In, Out]) GetDescription

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

GetDescription returns the `Description` of the processor.

func (*Processor[In, Out]) GetName

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

GetName returns the `Name` of the processor.

func (*Processor[In, Out]) GetState

func (p *Processor[In, Out]) GetState() status.Status

GetState returns the `State` of the processor.

func (*Processor[In, Out]) Run

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

Run the transform function.

func (*Processor[In, Out]) SetState

func (p *Processor[In, Out]) SetState(state status.Status)

SetState sets the `State` of the processor.

Jump to

Keyboard shortcuts

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