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.

84 lines
1.6 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### demo ####### Copyright (c) 2021 mls-361 #################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package demo
import (
"forge.chapril.org/armen/runner"
"forge.chapril.org/armen/workers"
"forge.chapril.org/armen/armen/internal/components"
)
type demo struct {
logger components.Logger
pool *workers.Pool
}
var _demo *demo
func (d *demo) jt1(job *runner.Job) {
}
func Build(app components.Application, logger components.Logger, model components.Model) error {
if _, ok := app.LookupEnv("CONFIG"); ok {
return nil
}
if _, ok := app.LookupEnv("DEMO"); !ok {
return nil
}
d := &demo{
logger: logger,
}
r := runner.New("demo", model)
if err := r.AddJobHandler("jt1", runner.JHF(d.jt1)); err != nil {
return err
}
p, err := workers.NewPool(&workers.Config{
Logger: logger,
PoolSize: 2,
Model: model,
})
if err != nil {
return err
}
if err := p.AddRunner(r); err != nil {
return err
}
d.pool = p
_demo = d
return nil
}
func Start() {
if _demo == nil {
return
}
_demo.pool.Start()
_demo.logger.Notice("Demonstration mode is activated") //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
}
func Stop() {
if _demo == nil {
return
}
_demo.pool.Stop()
}
/*
######################################################################################################## @(°_°)@ #######
*/