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.
 
 
 

75 lines
1.7 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### main ####### Copyright (c) 2021 mls-361 #################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package main
import (
"time"
"forge.chapril.org/armen/factory"
"forge.chapril.org/armen/memory"
"forge.chapril.org/armen/model"
"forge.chapril.org/armen/runner"
"forge.chapril.org/armen/workers"
"forge.chapril.org/mls-361/logger"
"forge.chapril.org/mls-361/uuid"
)
var (
_version string
_builtAt string
)
func main() {
logger, _ := logger.New(uuid.New(), "armen", "trace", logger.NewStderrOutput())
logger.Trace("armen", "version", _version, "builtAt", _builtAt)
m, _ := model.New(&model.Config{
Logger: logger,
Storage: memory.New(),
})
f := factory.New(m)
r := runner.New("namespace", m)
_ = r.AddJobHandler("type", runner.JHF(func(job *runner.Job) {
//panic("just a test")
job.Pending().SetDuration(2 * time.Second).SetError("une simple erreur")
}))
pool, err := workers.NewPool(&workers.Config{
Logger: logger,
PoolSize: 3,
Model: m,
})
if err != nil {
logger.Fatal(err.Error())
return
}
_ = pool.AddRunner(r)
pool.Start()
time.Sleep(1 * time.Second)
_, _ = f.NewJob("namespace", "type").
SetName("name").
SetOrigin("origin").
SetPriorityLow().
SetRetries(1).
CreateJob()
time.Sleep(5 * time.Second)
pool.Stop()
time.Sleep(1 * time.Second)
}
/*
######################################################################################################## @(°_°)@ #######
*/