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.
 
 
 

90 lines
1.8 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
workers *workers.Pool
}
var _demo *demo
func Build(ccs *components.Components) error {
if _, ok := ccs.Application.LookupEnv("CONFIG"); ok {
return nil
}
if v, ok := ccs.Application.LookupEnv("DEMO"); !ok || v != "t" && v != "true" {
return nil
}
d := &demo{
logger: ccs.Logger,
}
r := runner.New("demo", ccs.Model)
if err := r.AddJobHandler("panic", runner.JHF(d.panic)); err != nil {
return err
}
if err := r.AddJobHandler("pending", runner.JHF(d.pending)); err != nil {
return err
}
if err := r.AddJobHandler("succeeded", runner.JHF(d.succeeded)); err != nil {
return err
}
if err := r.AddJobHandler("workflow", runner.JHF(d.workflow)); err != nil {
return err
}
p, err := workers.NewPool(&workers.Config{
Logger: ccs.Logger,
Runner: r,
PoolSize: 2,
Host: ccs.Application.Host(),
})
if err != nil {
return err
}
d.workers = p
_demo = d
return nil
}
func Start() {
if _demo == nil {
return
}
_demo.workers.Start()
_demo.logger.Notice("Demonstration mode is activated") //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
}
func Stop() {
if _demo == nil {
return
}
_demo.workers.Stop()
}
/*
######################################################################################################## @(°_°)@ #######
*/