cleanstack

package
v3.0.0-alpha.20251205 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanStack

type CleanStack struct {
	// contains filtered or unexported fields
}

Stack is a basic LIFO stack that resizes as needed.

func NewCleanStack

func NewCleanStack() *CleanStack

NewCleanStack returns a new stack.

func (*CleanStack) Cleanup

func (clean *CleanStack) Cleanup(err error) error

Cleanup runs the whole cleanup stack. In case of error it runs all jobs and returns the first error occurrence.

func (*CleanStack) Pop

func (clean *CleanStack) Pop() *Job

Pop removes and returns a node from the stack in last to first order.

func (*CleanStack) Push

func (clean *CleanStack) Push(task Task)

Push adds a node to the stack that will be always executed

func (*CleanStack) PushErrorOnly

func (clean *CleanStack) PushErrorOnly(task Task)

PushErrorOnly adds an error only node to the stack

func (*CleanStack) PushSuccessOnly

func (clean *CleanStack) PushSuccessOnly(task Task)

PushSuccessOnly adds a success only node to the stack

type Job

type Job struct {
	// contains filtered or unexported fields
}

Job represents a task. It can be of three different types: errorOnly type is a job only executed on error, successOnly type is executed only on sucess and always is always executed regardless the error value.

func (Job) Run

func (cj Job) Run() error

Run executes the defined job

func (Job) Type

func (cj Job) Type() int

Type returns the CleanJob type

type Task

type Task func() error

Jump to

Keyboard shortcuts

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