plumber

package module
v4.11.4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 28 Imported by: 2

README

plumber

Description

A library for creating quick and effective CLI applications that have the process management build inside it.



Documentation

Index

Constants

View Source
const (
	LOG_LEVEL_DEFAULT LogLevel = 0
	LOG_LEVEL_PANIC   LogLevel = logrus.PanicLevel
	LOG_LEVEL_FATAL   LogLevel = logrus.FatalLevel
	LOG_LEVEL_ERROR   LogLevel = logrus.ErrorLevel
	LOG_LEVEL_WARN    LogLevel = logrus.WarnLevel
	LOG_LEVEL_INFO    LogLevel = logrus.InfoLevel
	LOG_LEVEL_DEBUG   LogLevel = logrus.DebugLevel
	LOG_LEVEL_TRACE   LogLevel = logrus.TraceLevel
	LOG_FIELD_CONTEXT string   = "context"
	LOG_FIELD_STATUS  string   = "status"
)
View Source
const CLI_FLAGS_CATEGORY = "CLI"
View Source
const (
	MARK_ROUTINE string = "MARK_ROUTINE"
)

Variables

View Source
var CliDefaultFlags = []cli.Flag{
	&cli.BoolFlag{
		Category: CLI_FLAGS_CATEGORY,
		Name:     "ci",
		Usage:    "Sets whether this is running inside a CI/CD environment.",
		Hidden:   true,
		EnvVars:  []string{"CI"},
	},

	&cli.BoolFlag{
		Category: CLI_FLAGS_CATEGORY,
		Name:     "debug",
		Usage:    "Enable debugging for the application.",
		EnvVars:  []string{"DEBUG"},
		Hidden:   true,
	},

	&cli.StringFlag{
		Category: CLI_FLAGS_CATEGORY,
		Name:     "env-file",
		Usage:    "Environment files to inject.",
		EnvVars:  []string{"ENV_FILE"},
		Hidden:   true,
	},

	&cli.StringFlag{
		Category: CLI_FLAGS_CATEGORY,
		Name:     "log-level",
		Usage:    `Define the log level for the application. enum("PANIC", "FATAL", "WARNING", "INFO", "DEBUG", "TRACE")`,
		EnvVars:  []string{"LOG_LEVEL"},
		Value:    logrus.InfoLevel.String(),
	},
}

Functions

This section is empty.

Types

type AppChannel

type AppChannel struct {
	// to communicate the errors while not blocking
	Err chan error
	// to communicate the errors while not blocking
	CustomErr chan ErrorWithLogger
	// Fatal errors
	Fatal chan error
	// to communicate the errors while not blocking
	CustomFatal chan ErrorWithLogger
	// terminate channel
	Interrupt chan os.Signal
	// exit channel
	Exit *broadcaster.Broadcaster[int]
}

type AppEnvironment

type AppEnvironment struct {
	Debug bool
	CI    bool
}

type Command

type Command[Pipe TaskListData] struct {
	Command *exec.Cmd
	Plumber *Plumber

	Log *logrus.Entry
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand[Pipe TaskListData](
	task *Task[Pipe],
	command string,
	args ...string,
) *Command[Pipe]

func (*Command[Pipe]) AddSelfToTheParentTask

func (c *Command[Pipe]) AddSelfToTheParentTask(pt *Task[Pipe]) *Command[Pipe]

func (*Command[Pipe]) AddSelfToTheTask

func (c *Command[Pipe]) AddSelfToTheTask() *Command[Pipe]

func (*Command[Pipe]) AppendArgs

func (c *Command[Pipe]) AppendArgs(args ...string) *Command[Pipe]

Command.AppendArgs Appends arguments to the command.

func (*Command[Pipe]) AppendDirectEnvironment

func (c *Command[Pipe]) AppendDirectEnvironment(environment ...string) *Command[Pipe]

Command.AppendDirectEnvironment Appends environment variables to command as directly.

func (*Command[Pipe]) AppendEnvironment

func (c *Command[Pipe]) AppendEnvironment(environment map[string]string) *Command[Pipe]

Command.AppendEnvironment Appends environment variables to command as map.

func (*Command[Pipe]) EnableStreamRecording

func (c *Command[Pipe]) EnableStreamRecording() *Command[Pipe]

func (*Command[Pipe]) EnableTerminator

func (c *Command[Pipe]) EnableTerminator() *Command[Pipe]

func (*Command[Pipe]) EnsureIsAlive

func (c *Command[Pipe]) EnsureIsAlive() *Command[Pipe]

func (*Command[Pipe]) GetCombinedStream

func (c *Command[Pipe]) GetCombinedStream() []string

func (*Command[Pipe]) GetFormattedCommand

func (c *Command[Pipe]) GetFormattedCommand() string

func (*Command[Pipe]) GetStderrStream

func (c *Command[Pipe]) GetStderrStream() []string

func (*Command[Pipe]) GetStdoutStream

func (c *Command[Pipe]) GetStdoutStream() []string

func (*Command[Pipe]) IsDisabled

func (c *Command[Pipe]) IsDisabled() bool

func (*Command[Pipe]) Job

func (c *Command[Pipe]) Job() Job

func (*Command[Pipe]) Run

func (c *Command[Pipe]) Run() error

Command.Run Run the defined command.

func (*Command[Pipe]) RunSet

func (c *Command[Pipe]) RunSet() error

func (*Command[Pipe]) Set

func (c *Command[Pipe]) Set(fn CommandFn[Pipe]) *Command[Pipe]

Command.Set Sets the command details.

func (*Command[Pipe]) SetDir

func (c *Command[Pipe]) SetDir(dir string) *Command[Pipe]

Command.SetDir Sets the directory of the command.

func (*Command[Pipe]) SetIgnoreError

func (c *Command[Pipe]) SetIgnoreError() *Command[Pipe]

func (*Command[Pipe]) SetLogLevel

func (c *Command[Pipe]) SetLogLevel(
	stdout LogLevel,
	stderr LogLevel,
	lifetime LogLevel,
) *Command[Pipe]

Command.SetLogLevel Sets the log level specific to this command.

func (*Command[Pipe]) SetMaskOsEnvironment

func (c *Command[Pipe]) SetMaskOsEnvironment() *Command[Pipe]

func (*Command[Pipe]) SetOnTerminator

func (c *Command[Pipe]) SetOnTerminator(fn CommandFn[Pipe]) *Command[Pipe]

func (*Command[Pipe]) SetPath

func (c *Command[Pipe]) SetPath(dir string) *Command[Pipe]

Command.SetPath Sets the directory of the command.

func (*Command[Pipe]) ShouldDisable

func (c *Command[Pipe]) ShouldDisable(fn TaskPredicateFn[Pipe]) *Command[Pipe]

func (*Command[Pipe]) ShouldRunAfter

func (c *Command[Pipe]) ShouldRunAfter(fn CommandFn[Pipe]) *Command[Pipe]

type CommandFn

type CommandFn[Pipe TaskListData] func(*Command[Pipe]) error

type CommandOptions

type CommandOptions[Pipe TaskListData] struct {
	Disable TaskPredicateFn[Pipe]
}

type DeprecationNotice

type DeprecationNotice struct {
	Message     string
	Environment []string
	Flag        []string
	Level       LogLevel
}

type ErrorWithLogger

type ErrorWithLogger struct {
	Log *logrus.Entry
	Err error
}

type GuardHandlerFn

type GuardHandlerFn[Pipe TaskListData] func(*TaskList[Pipe])

type Job

type Job = floc.Job

type JobPredicate

type JobPredicate = floc.Predicate

type JobWrapperFn

type JobWrapperFn func(job Job) Job

type LogLevel

type LogLevel = logrus.Level

type Plumber

type Plumber struct {
	Cli         *cli.App
	Log         *logrus.Logger
	Environment AppEnvironment
	Channel     AppChannel
	Terminator

	PlumberOnTerminateFn

	DocsFile                        string
	DocsExcludeFlags                bool
	DocsExcludeEnvironmentVariables bool
	DocsExcludeHelpCommand          bool

	DeprecationNotices []DeprecationNotice
	// contains filtered or unexported fields
}

func (*Plumber) AppendFlags

func (p *Plumber) AppendFlags(flags ...[]cli.Flag) []cli.Flag

Cli.AppendFlags Appends flags together.

func (*Plumber) AppendSecrets

func (p *Plumber) AppendSecrets(secrets ...string) *Plumber

func (*Plumber) EnableTerminator

func (p *Plumber) EnableTerminator() *Plumber

func (*Plumber) New

func (p *Plumber) New(
	fn func(a *Plumber) *cli.App,
) *Plumber

Cli.New Creates a new plumber for pipes.

func (*Plumber) RegisterTerminated

func (p *Plumber) RegisterTerminated() *Plumber

func (*Plumber) RegisterTerminator

func (p *Plumber) RegisterTerminator() *Plumber

func (*Plumber) Run

func (p *Plumber) Run()

Cli.Run Starts the application.

func (*Plumber) SendCustomError

func (p *Plumber) SendCustomError(log *logrus.Entry, err error) *Plumber

func (*Plumber) SendCustomFatal

func (p *Plumber) SendCustomFatal(log *logrus.Entry, err error) *Plumber

func (*Plumber) SendError

func (p *Plumber) SendError(err error) *Plumber

func (*Plumber) SendExit

func (p *Plumber) SendExit(code int) *Plumber

func (*Plumber) SendFatal

func (p *Plumber) SendFatal(err error) *Plumber

func (*Plumber) SendTerminate

func (p *Plumber) SendTerminate(sig os.Signal, code int)

func (*Plumber) SetOnTerminate

func (p *Plumber) SetOnTerminate(fn PlumberOnTerminateFn) *Plumber

Cli.SetOnTerminate Sets the action that would be executed on terminate.

func (*Plumber) Terminate

func (p *Plumber) Terminate(code int)

App.Terminate Terminates the application.

type PlumberOnTerminateFn

type PlumberOnTerminateFn func() error

type Result

type Result = floc.Result
const (
	TASK_ANY       Result = floc.None
	TASK_COMPLETED Result = floc.Completed
	TASK_CANCELLED Result = floc.Canceled
	TASK_FAILED    Result = floc.Failed
)

type ResultMask

type ResultMask = floc.ResultMask

type Task

type Task[Pipe TaskListData] struct {
	Name string

	Plumber *Plumber
	Log     *logrus.Entry
	Channel *AppChannel
	Lock    *sync.RWMutex

	Pipe    *Pipe
	Control floc.Control
	// contains filtered or unexported fields
}

func NewTask

func NewTask[Pipe TaskListData](tl *TaskList[Pipe], name ...string) *Task[Pipe]

func (*Task[Pipe]) AddCommands

func (t *Task[Pipe]) AddCommands(commands ...*Command[Pipe]) *Task[Pipe]

func (*Task[Pipe]) AddSelfToTheParent

func (t *Task[Pipe]) AddSelfToTheParent(
	fn func(pt *Task[Pipe], st *Task[Pipe]),
) *Task[Pipe]

func (*Task[Pipe]) AddSelfToTheParentAsParallel

func (t *Task[Pipe]) AddSelfToTheParentAsParallel() *Task[Pipe]

func (*Task[Pipe]) AddSelfToTheParentAsSequence

func (t *Task[Pipe]) AddSelfToTheParentAsSequence() *Task[Pipe]

func (*Task[Pipe]) CreateCommand

func (t *Task[Pipe]) CreateCommand(command string, args ...string) *Command[Pipe]

func (*Task[Pipe]) CreateSubtask

func (t *Task[Pipe]) CreateSubtask(name ...string) *Task[Pipe]

func (*Task[Pipe]) EnableTerminator

func (t *Task[Pipe]) EnableTerminator() *Task[Pipe]

func (*Task[Pipe]) ExtendSubtask

func (t *Task[Pipe]) ExtendSubtask(fn JobWrapperFn) *Task[Pipe]

func (*Task[Pipe]) GetCommandJobAsJobParallel

func (t *Task[Pipe]) GetCommandJobAsJobParallel() Job

func (*Task[Pipe]) GetCommandJobAsJobSequence

func (t *Task[Pipe]) GetCommandJobAsJobSequence() Job

func (*Task[Pipe]) GetCommandJobs

func (t *Task[Pipe]) GetCommandJobs() []Job

func (*Task[Pipe]) GetCommands

func (t *Task[Pipe]) GetCommands() []*Command[Pipe]

func (*Task[Pipe]) GetSubtasks

func (t *Task[Pipe]) GetSubtasks() Job

func (*Task[Pipe]) HasParent

func (t *Task[Pipe]) HasParent() bool

func (*Task[Pipe]) IsDisabled

func (t *Task[Pipe]) IsDisabled() bool

func (*Task[Pipe]) IsMarkedAsRoutine

func (t *Task[Pipe]) IsMarkedAsRoutine() bool

func (*Task[Pipe]) IsSkipped

func (t *Task[Pipe]) IsSkipped() bool

func (*Task[Pipe]) Job

func (t *Task[Pipe]) Job() Job

func (*Task[Pipe]) Run

func (t *Task[Pipe]) Run() error

func (*Task[Pipe]) RunCommandJobAsJobParallel

func (t *Task[Pipe]) RunCommandJobAsJobParallel() error

func (*Task[Pipe]) RunCommandJobAsJobParallelWithExtension

func (t *Task[Pipe]) RunCommandJobAsJobParallelWithExtension(fn JobWrapperFn) error

func (*Task[Pipe]) RunCommandJobAsJobSequence

func (t *Task[Pipe]) RunCommandJobAsJobSequence() error

func (*Task[Pipe]) RunCommandJobAsJobSequenceWithExtension

func (t *Task[Pipe]) RunCommandJobAsJobSequenceWithExtension(fn JobWrapperFn) error

func (*Task[Pipe]) RunSubtasks

func (t *Task[Pipe]) RunSubtasks() error

func (*Task[Pipe]) RunSubtasksWithExtension

func (t *Task[Pipe]) RunSubtasksWithExtension(fn func(job Job) Job) error

func (*Task[Pipe]) SendError

func (t *Task[Pipe]) SendError(err error) *Task[Pipe]

func (*Task[Pipe]) SendExit

func (t *Task[Pipe]) SendExit(code int) *Task[Pipe]

func (*Task[Pipe]) SendFatal

func (t *Task[Pipe]) SendFatal(err error) *Task[Pipe]

func (*Task[Pipe]) Set

func (t *Task[Pipe]) Set(fn TaskFn[Pipe]) *Task[Pipe]

func (*Task[Pipe]) SetJobWrapper

func (t *Task[Pipe]) SetJobWrapper(fn JobWrapperFn) *Task[Pipe]

func (*Task[Pipe]) SetMarks

func (t *Task[Pipe]) SetMarks(marks ...string) *Task[Pipe]

func (*Task[Pipe]) SetOnTerminator

func (t *Task[Pipe]) SetOnTerminator(fn TaskFn[Pipe]) *Task[Pipe]

func (*Task[Pipe]) SetSubtask

func (t *Task[Pipe]) SetSubtask(job Job) *Task[Pipe]

func (*Task[Pipe]) ShouldDisable

func (t *Task[Pipe]) ShouldDisable(fn TaskPredicateFn[Pipe]) *Task[Pipe]

func (*Task[Pipe]) ShouldRunAfter

func (t *Task[Pipe]) ShouldRunAfter(fn TaskFn[Pipe]) *Task[Pipe]

func (*Task[Pipe]) ShouldRunBefore

func (t *Task[Pipe]) ShouldRunBefore(fn TaskFn[Pipe]) *Task[Pipe]

func (*Task[Pipe]) ShouldSkip

func (t *Task[Pipe]) ShouldSkip(fn TaskPredicateFn[Pipe]) *Task[Pipe]

func (*Task[Pipe]) ToParent

func (t *Task[Pipe]) ToParent(
	parent *Task[Pipe],
	fn func(pt *Task[Pipe], st *Task[Pipe]),
) *Task[Pipe]

type TaskFn

type TaskFn[Pipe TaskListData] func(t *Task[Pipe]) error

type TaskList

type TaskList[Pipe TaskListData] struct {
	Tasks Job

	Plumber *Plumber

	CliContext *cli.Context
	Pipe       Pipe
	Lock       *sync.RWMutex
	Log        *logrus.Logger
	Channel    *AppChannel
	Control    floc.Control
	// contains filtered or unexported fields
}

func (*TaskList[Pipe]) CreateBasicJob

func (t *TaskList[Pipe]) CreateBasicJob(fn func() error) Job

func (*TaskList[Pipe]) CreateJob

func (t *TaskList[Pipe]) CreateJob(fn func(tl *TaskList[Pipe]) error) Job

func (*TaskList[Pipe]) CreateTask

func (t *TaskList[Pipe]) CreateTask(name ...string) *Task[Pipe]

func (*TaskList[Pipe]) GetTasks

func (t *TaskList[Pipe]) GetTasks() Job

func (*TaskList[Pipe]) GuardAlways

func (t *TaskList[Pipe]) GuardAlways(job Job) Job

Always run this job!

func (*TaskList[Pipe]) GuardIgnorePanic

func (t *TaskList[Pipe]) GuardIgnorePanic(job Job) Job

func (*TaskList[Pipe]) GuardOnPanic

func (t *TaskList[Pipe]) GuardOnPanic(job Job, fn GuardHandlerFn[Pipe]) Job

OnPanic protects the job from falling into panic. In addition it takes PanicTrigger func which is called in case of panic. Guarding the job from falling into panic is effective only if the job runs in the current goroutine.

func (*TaskList[Pipe]) GuardOnTimeout

func (t *TaskList[Pipe]) GuardOnTimeout(
	job Job,
	fn GuardHandlerFn[Pipe],
	timeout time.Duration,
) Job

OnTimeout protects the job from taking too much time on execution. In addition it takes TimeoutTrigger func (t *TaskList[Pipe]) which called if time is out. The job is run in it's own goroutine while the current goroutine waits until the job finished or time went out or the flow is finished.

func (*TaskList[Pipe]) GuardPanic

func (t *TaskList[Pipe]) GuardPanic(job Job) Job

Panic protects the job from falling into panic. On panic the flow will be canceled with the ErrPanic result. Guarding the job from falling into panic is effective only if the job runs in the current goroutine.

func (*TaskList[Pipe]) GuardResume

func (t *TaskList[Pipe]) GuardResume(job Job, mask Result) Job

Resume resumes execution of the flow possibly finished by the job. If the mask is empty execution will be resumed regardless the reason it was finished. Otherwise execution will be resumed if the reason it finished with is masked.

func (*TaskList[Pipe]) GuardTimeout

func (t *TaskList[Pipe]) GuardTimeout(job Job, timeout time.Duration) Job

GuardTimeout protects the job from taking too much time on execution. The job is run in it's own goroutine while the current goroutine waits until the job finished or time went out or the flow is finished.

func (*TaskList[Pipe]) Job

func (t *TaskList[Pipe]) Job() Job

func (*TaskList[Pipe]) JobBackground

func (t *TaskList[Pipe]) JobBackground(job Job) Job

JobBackground starts the job in it's own goroutine. The function does not track the lifecycle of the job started and does no synchronization with it therefore the job running in background may remain active even if the flow is finished. The function assumes the job is aware of the flow state and/or synchronization and termination of it is implemented outside.

floc.Run(run.Background(
	func(ctx floc.Context, ctrl floc.Control) error {
		for !ctrl.IsFinished() {
			fmt.Println(time.Now())
		}

		return nil
	}
})

Summary:

  • Run jobs in goroutines : YES
  • Wait all jobs finish : NO
  • Run order : SINGLE

Diagram:

--+----------->
  |
  +-->[JOB]

func (*TaskList[Pipe]) JobDelay

func (t *TaskList[Pipe]) JobDelay(job Job, delay time.Duration) Job

JobDelay does delay before starting the job.

Summary:

  • Run jobs in goroutines : NO
  • Wait all jobs finish : YES
  • Run order : SINGLE

Diagram:

--(DELAY)-->[JOB]-->

func (*TaskList[Pipe]) JobElse

func (t *TaskList[Pipe]) JobElse(job Job) Job

JobElse just returns the job unmodified. Else is used for expressiveness and can be omitted.

Summary:

  • Run jobs in goroutines : N/A
  • Wait all jobs finish : N/A
  • Run order : N/A

Diagram:

----[JOB]--->

func (*TaskList[Pipe]) JobIf

func (t *TaskList[Pipe]) JobIf(predicate JobPredicate, jobs ...Job) Job

JobIf runs the first job if the condition is met and runs the second job, if it's passed, if the condition is not met. The function panics if no or more than two jobs are given.

For expressiveness Then() and Else() can be used.

flow := run.If(testSomething,
  run.Then(doSomething),
  run.Else(doSomethingElse),
)

Summary:

  • Run jobs in goroutines : NO
  • Wait all jobs finish : YES
  • Run order : SINGLE

Diagram:

                    +----->[JOB_1]---+
                    | YES            |
--(CONDITION MET?)--+                +-->
                    | NO             |
                    +----->[JOB_2]---+

func (*TaskList[Pipe]) JobIfNot

func (t *TaskList[Pipe]) JobIfNot(predicate JobPredicate, jobs ...Job) Job

JobIfNot runs the first job if the condition is not met and runs the second job, if it's passed, if the condition is met. The function panics if no or more than two jobs are given.

For expressiveness Then() and Else() can be used.

flow := run.IfNot(testSomething,
  run.Then(doSomething),
  run.Else(doSomethingElse),
)

Summary:

  • Run jobs in goroutines : NO
  • Wait all jobs finish : YES
  • Run order : SINGLE

Diagram:

                    +----->[JOB_1]---+
                    | NO             |
--(CONDITION MET?)--+                +-->
                    | YES            |
                    +----->[JOB_2]---+

func (*TaskList[Pipe]) JobLoop

func (t *TaskList[Pipe]) JobLoop(job Job) Job

JobLoop repeats running the job forever.

Summary:

  • Run jobs in goroutines : NO
  • Wait all jobs finish : YES
  • Run order : SINGLE

Diagram:

  +----------+
  |          |
  V          |
----->[JOB]--+

func (*TaskList[Pipe]) JobLoopWithWaitAfter

func (t *TaskList[Pipe]) JobLoopWithWaitAfter(job Job, delay time.Duration) Job

func (*TaskList[Pipe]) JobParallel

func (t *TaskList[Pipe]) JobParallel(jobs ...Job) Job

JobParallel runs jobs in their own goroutines and waits until all of them finish.

Summary:

  • Run jobs in goroutines : YES
  • Wait all jobs finish : YES
  • Run order : PARALLEL

Diagram:

  +-->[JOB_1]--+
  |            |
--+-->  ..   --+-->
  |            |
  +-->[JOB_N]--+

func (*TaskList[Pipe]) JobRepeat

func (t *TaskList[Pipe]) JobRepeat(job Job, times int) Job

JobRepeat repeats running the job for N times.

Summary:

  • Run jobs in goroutines : NO
  • Wait all jobs finish : YES
  • Run order : SINGLE

Diagram:

                        NO
  +-----------[JOB]<---------+
  |                          |
  V                          | YES
----(ITERATED COUNT TIMES?)--+---->

func (*TaskList[Pipe]) JobSequence

func (t *TaskList[Pipe]) JobSequence(jobs ...Job) Job

JobSequence runs jobs sequentially, one by one.

Summary:

  • Run jobs in goroutines : NO
  • Wait all jobs finish : YES
  • Run order : SEQUENCE

Diagram:

-->[JOB_1]-...->[JOB_N]-->

func (*TaskList[Pipe]) JobThen

func (t *TaskList[Pipe]) JobThen(job Job) Job

Then just returns the job unmodified. Then is used for expressiveness and can be omitted.

Summary:

  • Run jobs in goroutines : N/A
  • Wait all jobs finish : N/A
  • Run order : N/A

Diagram:

----[JOB]--->

func (*TaskList[Pipe]) JobWait

func (t *TaskList[Pipe]) JobWait(predicate JobPredicate, sleep time.Duration) Job

JobWait waits until the condition is met. The function falls into sleep with the duration given between condition checks. The function does not run any job actually and just repeatedly checks predicate's return value. When the predicate returns true the function finishes.

Summary:

  • Run jobs in goroutines : N/A
  • Wait all jobs finish : N/A
  • Run order : N/A

Diagram:

                  NO
  +------(SLEEP)------+
  |                   |
  V                   | YES
----(CONDITION MET?)--+----->

func (*TaskList[Pipe]) JobWaitForTerminator

func (t *TaskList[Pipe]) JobWaitForTerminator() Job

func (*TaskList[Pipe]) JobWhile

func (t *TaskList[Pipe]) JobWhile(predicate JobPredicate, job Job) Job

JobWhile repeats running the job while the condition is met.

Summary:

  • Run jobs in goroutines : NO
  • Wait all jobs finish : YES
  • Run order : SINGLE

Diagram:

                  YES
  +-------[JOB]<------+
  |                   |
  V                   | NO
----(CONDITION MET?)--+---->

func (*TaskList[Pipe]) New

func (t *TaskList[Pipe]) New(p *Plumber) *TaskList[Pipe]

func (*TaskList[Pipe]) NewResultMask

func (t *TaskList[Pipe]) NewResultMask(mask Result) ResultMask

NewResultMask constructs new instance from the mask given.

func (*TaskList[Pipe]) Predicate

func (t *TaskList[Pipe]) Predicate(fn TaskListPredicateFn[Pipe]) JobPredicate

TaskList.Predicate Creates a new floc predicate out of the given conditions.

func (*TaskList[Pipe]) PredicateAnd

func (t *TaskList[Pipe]) PredicateAnd(predicates ...JobPredicate) JobPredicate

PredicateAnd returns a predicate which chains multiple predicates into a condition with AND logic. The result predicate finishes calculation of the condition as fast as the result is known. The function panics if the number of predicates is less than 2.

The result predicate tests the condition as follows.

[PRED_1] AND ... AND [PRED_N]

func (*TaskList[Pipe]) PredicateNot

func (t *TaskList[Pipe]) PredicateNot(predicate JobPredicate) JobPredicate

PredicateNot returns the negated value of the predicate.

The result predicate tests the condition as follows.

NOT [PRED]

func (*TaskList[Pipe]) PredicateOr

func (t *TaskList[Pipe]) PredicateOr(predicates ...JobPredicate) JobPredicate

PredicateOr returns a predicate which chains multiple predicates into a condition with OR logic. The result predicate finishes calculation of the condition as fast as the result is known.

The result predicate tests the condition as follows.

[PRED_1] OR ... OR [PRED_N]

func (*TaskList[Pipe]) PredicateXor

func (t *TaskList[Pipe]) PredicateXor(predicates ...JobPredicate) JobPredicate

Xor returns a predicate which chains multiple predicates into a condition with XOR logic. The result predicate finishes calculation of the condition as fast as the result is known.

The result predicate tests the condition as follows.

(([PRED_1] XOR [PRED_2]) ... XOR [PRED_N])

func (*TaskList[Pipe]) Run

func (t *TaskList[Pipe]) Run() error

func (*TaskList[Pipe]) RunJobs

func (t *TaskList[Pipe]) RunJobs(job Job) error

func (*TaskList[Pipe]) Set

func (t *TaskList[Pipe]) Set(fn TaskListJobFn[Pipe]) *TaskList[Pipe]

func (*TaskList[Pipe]) SetCliContext

func (t *TaskList[Pipe]) SetCliContext(ctx *cli.Context) *TaskList[Pipe]

func (*TaskList[Pipe]) SetDelimiter

func (t *TaskList[Pipe]) SetDelimiter(delimiter string) *TaskList[Pipe]

func (*TaskList[Pipe]) SetTasks

func (t *TaskList[Pipe]) SetTasks(tasks Job) *TaskList[Pipe]

func (*TaskList[Pipe]) ShouldRunAfter

func (t *TaskList[Pipe]) ShouldRunAfter(fn TaskListFn[Pipe]) *TaskList[Pipe]

func (*TaskList[Pipe]) ShouldRunBefore

func (t *TaskList[Pipe]) ShouldRunBefore(fn TaskListFn[Pipe]) *TaskList[Pipe]

func (*TaskList[Pipe]) Validate

func (t *TaskList[Pipe]) Validate(data TaskListData) error

type TaskListData

type TaskListData interface {
	any
}

type TaskListFn

type TaskListFn[Pipe TaskListData] func(*TaskList[Pipe]) error

type TaskListJobFn

type TaskListJobFn[Pipe TaskListData] func(*TaskList[Pipe]) Job

type TaskListPredicateFn

type TaskListPredicateFn[Pipe TaskListData] func(*TaskList[Pipe]) bool

type TaskOptions

type TaskOptions[Pipe TaskListData] struct {
	Skip    TaskPredicateFn[Pipe]
	Disable TaskPredicateFn[Pipe]
}

type TaskPredicateFn

type TaskPredicateFn[Pipe TaskListData] func(t *Task[Pipe]) bool

type Terminator

type Terminator struct {
	Enabled         bool
	ShouldTerminate *broadcaster.Broadcaster[os.Signal]
	Terminated      *broadcaster.Broadcaster[bool]
	Lock            *sync.RWMutex
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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