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.
 
 
 

69 lines
1.6 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### main ####### Copyright (c) 2021 mls-361 #################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package main
import (
"time"
"forge.chapril.org/armen/armen-jw/factory"
"forge.chapril.org/armen/armen-jw/model"
"forge.chapril.org/armen/armen-namespace/runner"
"forge.chapril.org/armen/armen-sdk/logger"
"forge.chapril.org/armen/armen-sdk/sdk"
"forge.chapril.org/armen/armen-workers/pool"
)
var (
_version string
_builtAt string
)
func main() {
logger := logger.Default
logger.Trace("armen", sdk.Fields{"version": _version, "builtAt": _builtAt})
m := model.New(&model.Config{})
factory := factory.New(m)
nsRunner := runner.New("namespace", m)
_ = nsRunner.AddJobHandler("type", runner.JHF(func(job *runner.Job) *model.JobR {
//panic("just a test")
return model.JobPending().SetDuration(1 * time.Second)
}))
pool, err := pool.New(&pool.Config{
Size: 3,
Model: m,
})
if err != nil {
logger.Fatal(err.Error(), nil)
return
}
_ = pool.AddRunner(nsRunner)
pool.Start()
time.Sleep(1 * time.Second)
_, _ = factory.NewJob("namespace", "type").
SetName("name").
SetOrigin("origin").
SetPriorityLow().
CreateJob()
time.Sleep(1 * time.Second)
pool.Stop()
time.Sleep(1 * time.Second)
}
/*
######################################################################################################## @(°_°)@ #######
*/