step

package
v0.0.0-...-792b534 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

In many cases such as restoring backups, jobs can be quite complex and should/can be broken down into smaller steps

Step is an utility structure that allows breaking down jobs complete with persist support

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Step

type Step[T any] struct {
	State string

	// By default, steps of a lower index are ignored
	// Steps may however have an equal index in which case the step that is first in the array is first executed
	Index int

	// Exec will either return the output and/which ends the job, the new progress for the job
	// or an error to quickly abort the stepping
	Exec func(
		self *T,
		l *zap.Logger,
		state jobstate.State,
		progstate jobstate.ProgressState,
		progress *jobstate.Progress,
	) (*types.Output, *jobstate.Progress, error)
}

type Stepper

type Stepper[T any] struct {
	// contains filtered or unexported fields
}

func NewStepper

func NewStepper[T any](steps ...Step[T]) *Stepper[T]

NewStepper creates a new stepper

func (*Stepper[T]) Exec

func (s *Stepper[T]) Exec(
	self *T,
	l *zap.Logger,
	state jobstate.State,
	progstate jobstate.ProgressState,
) (*types.Output, error)

Exec executes all steps, skipping over steps with a lower index

func (*Stepper[T]) Step

func (s *Stepper[T]) Step(state string) (*Step[T], bool)

Step returns a step based on its state

func (*Stepper[T]) StepIndex

func (s *Stepper[T]) StepIndex(state string) int

StepPosition returns the index of a step

Jump to

Keyboard shortcuts

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