Jobs & Workflows https://armen.surge.sh
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

76 lines
1.8 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### demo ####### Copyright (c) 2021 mls-361 #################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package demo
import (
"time"
"forge.chapril.org/armen/jw"
"forge.chapril.org/armen/runner"
)
func (d *demo) panic(_ *runner.Job) {
panic("it's only a test") //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
func (d *demo) pending(job *runner.Job) {
v, ok := job.Private["count"]
if ok {
count, ok := v.(int)
if ok {
if count == 3 {
// end
return
}
job.SetPrivate("count", count+1)
} else {
job.Failed().SetError("bug")
}
} else {
job.SetPrivate("count", 0)
}
job.Pending().SetDuration(time.Second)
}
func (d *demo) succeeded(_ *runner.Job) {
// nothing to do
}
func (d *demo) workflow(job *runner.Job) {
allSteps := map[string]*jw.Step{
"stepA": &jw.Step{
Namespace: "demo",
Type: "succeeded",
Next: map[string]interface{}{"succeeded": "stepB"},
},
"stepB": &jw.Step{
Namespace: "demo",
Type: "pending",
},
}
_, err := job.Factory.NewWorkflow("stepA", allSteps).
SetDescription("Demonstration worflow").
SetOrigin("demo").
CreateWorkflow()
if err != nil {
job.Logger.Error( //////////////////////////////////////////////////////////////////////////////////////////////
"Create workflow error",
"reason", err,
)
job.Failed().SetError(err.Error())
return
}
}
/*
######################################################################################################## @(°_°)@ #######
*/