Documentation ¶
Overview ¶
Package loader provides a framework for creating loaders.
Index ¶
- Constants
- type Func
- type ILoader
- type Load
- type Loader
- func (c *Loader[In, Out]) GetCounterCreated() *expvar.Int
- func (c *Loader[In, Out]) GetCounterDone() *expvar.Int
- func (c *Loader[In, Out]) GetCounterFailed() *expvar.Int
- func (c *Loader[In, Out]) GetCounterRunning() *expvar.Int
- func (c *Loader[In, Out]) GetCreatedAt() time.Time
- func (c *Loader[In, Out]) GetDescription() string
- func (c *Loader[In, Out]) GetDuration() *expvar.Int
- func (c *Loader[In, Out]) GetLogger() sypl.ISypl
- func (c *Loader[In, Out]) GetMetrics() map[string]string
- func (c *Loader[In, Out]) GetName() string
- func (c *Loader[In, Out]) GetOnFinished() OnFinished[In, Out]
- func (c *Loader[In, Out]) GetStatus() *expvar.String
- func (c *Loader[In, Out]) GetType() string
- func (c *Loader[In, Out]) Run(ctx context.Context, in In) (Out, error)
- func (c *Loader[In, Out]) SetOnFinished(onFinished OnFinished[In, Out])
- type OnFinished
Constants ¶
const Type = "loader"
Type of the entity.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶
Func allows to specify message's options.
func WithOnFinished ¶
func WithOnFinished[In, Out any](onFinished OnFinished[In, Out]) Func[In, Out]
WithOnFinished sets the OnFinished function.
type ILoader ¶
type ILoader[In, Out any] interface { shared.IMeta shared.IMetrics // GetOnFinished returns the `OnFinished` function. GetOnFinished() OnFinished[In, Out] // SetOnFinished sets the `OnFinished` function. SetOnFinished(onFinished OnFinished[In, Out]) // Run the stage function. Run(ctx context.Context, in In) (Out, error) }
ILoader defines what a `Conveter` must do.
type Load ¶
Load is a function that converts the data (`in`). It returns the converted data and any errors that occurred during conversion.
type Loader ¶
type Loader[In, Out any] struct { // Description of the processor. Description string `json:"description"` // Conversion function. Func Load[In, Out] `json:"-"` // Logger is the internal logger. Logger sypl.ISypl `json:"-" validate:"required"` // Name of the stage. Name string `json:"name" validate:"required"` // OnFinished is the function that is called when a processor finishes its // execution. OnFinished OnFinished[In, Out] `json:"-"` // Metrics. CounterCreated *expvar.Int `json:"counterCreated"` CounterRunning *expvar.Int `json:"counterRunning"` CounterFailed *expvar.Int `json:"counterFailed"` CounterDone *expvar.Int `json:"counterDone"` CreatedAt time.Time `json:"createdAt"` Duration *expvar.Int `json:"duration"` Status *expvar.String `json:"status"` }
Loader definition.
func (*Loader[In, Out]) GetCounterCreated ¶
GetCounterCreated returns the `CounterCreated` of the processor.
func (*Loader[In, Out]) GetCounterDone ¶
GetCounterDone returns the `CounterDone` of the processor.
func (*Loader[In, Out]) GetCounterFailed ¶
GetCounterFailed returns the `CounterFailed` of the processor.
func (*Loader[In, Out]) GetCounterRunning ¶
GetCounterRunning returns the `CounterRunning` of the processor.
func (*Loader[In, Out]) GetCreatedAt ¶
GetCreatedAt returns the created at time.
func (*Loader[In, Out]) GetDescription ¶
GetDescription returns the `Description` of the processor.
func (*Loader[In, Out]) GetDuration ¶
GetDuration returns the `CounterDuration` of the stage.
func (*Loader[In, Out]) GetMetrics ¶
GetMetrics returns the stage's metrics.
func (*Loader[In, Out]) GetOnFinished ¶
func (c *Loader[In, Out]) GetOnFinished() OnFinished[In, Out]
GetOnFinished returns the `OnFinished` function.
func (*Loader[In, Out]) SetOnFinished ¶
func (c *Loader[In, Out]) SetOnFinished(onFinished OnFinished[In, Out])
SetOnFinished sets the `OnFinished` function.