Gestionnaire de jobs et workflows
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.

54 lines
1.2 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package demo
import (
"forge.chapril.org/dune/sdk/runner"
"forge.chapril.org/dune/sdk/workers"
"forge.chapril.org/losyme/logger"
)
const _workerPoolSize = 2
type Demo struct {
*workers.Workers
}
func New(namespace string, logger *logger.Component, model runner.Model) (*Demo, error) {
r := runner.New(namespace, model)
cfg := &workers.Config{
PoolSize: _workerPoolSize,
Runner: r,
Logger: newWorkersLogger(logger),
}
workers, err := workers.New(cfg)
if err != nil {
return nil, err
}
demo := &Demo{
Workers: workers,
}
handlers := map[string]func(*runner.Job){
"succeeded": demo.succeeded,
}
for jt, jh := range handlers {
if err := r.AddJobHandler(jt, runner.JHF(jh)); err != nil {
return nil, err
}
}
return demo, nil
}
/*
######################################################################################################## @(°_°)@ #######
*/