Browse Source

En cours de développement

master
losyme 2 months ago
parent
commit
3c48d34ea7
  1. 2
      internal/application/demo.go
  2. 10
      internal/demo/demo.go
  3. 29
      internal/demo/jobs.go

2
internal/application/demo.go

@ -11,7 +11,7 @@ import "forge.chapril.org/dune/dune/internal/demo"
func (app *Application) demo() error {
cs := app.components
c, err := demo.New(cs.Application.Name(), cs.Logger.Component, cs.Model)
c, err := demo.New(cs.Logger.Component, cs.Model)
if err != nil {
return err
}

10
internal/demo/demo.go

@ -12,14 +12,17 @@ import (
"forge.chapril.org/losyme/logger"
)
const _workerPoolSize = 2
const (
_namespace = "demo"
_workerPoolSize = 2
)
type Demo struct {
*workers.Workers
}
func New(namespace string, logger *logger.Component, model runner.Model) (*Demo, error) {
r := runner.New(namespace, model)
func New(logger *logger.Component, model runner.Model) (*Demo, error) {
r := runner.New(_namespace, model)
cfg := &workers.Config{
PoolSize: _workerPoolSize,
@ -41,6 +44,7 @@ func New(namespace string, logger *logger.Component, model runner.Model) (*Demo,
"failed": demo.failed,
"panic": demo.panic,
"pending": demo.pending,
"workflow": demo.workflow,
}
for jt, jh := range handlers {

29
internal/demo/jobs.go

@ -9,6 +9,7 @@ package demo
import (
"time"
"forge.chapril.org/dune/jw"
"forge.chapril.org/dune/sdk/runner"
)
@ -43,6 +44,34 @@ func (d *Demo) pending(job *runner.Job) {
job.Pending().SetDuration(2 * time.Second)
}
func (d *Demo) workflow(job *runner.Job) {
allSteps := map[string]*jw.Step{
"firstStep": &jw.Step{
Namespace: _namespace,
Type: "pending",
Next: map[string]interface{}{"succeeded": "secondStep"},
},
"secondStep": &jw.Step{
Namespace: _namespace,
Type: "succeeded",
},
}
_, err := job.Factory.NewWorkflow("stepA", allSteps).
SetDescription("Demonstration worflow").
SetOrigin("demo").
CreateWorkflow()
if err != nil {
job.Logger.Error( //////////////////////////////////////////////////////////////////////////////////////////////
"Create workflow error",
"reason", err,
)
job.Failed().SetError(err.Error())
return
}
}
/*
######################################################################################################## @(°_°)@ #######
*/

Loading…
Cancel
Save