Browse Source

En cours de développement

master
mls-361 2 months ago
parent
commit
f73dc368e3
  1. 2
      go.mod
  2. 4
      go.sum
  3. 43
      internal/demo/demo.go

2
go.mod

@ -7,7 +7,7 @@ require (
forge.chapril.org/armen/memory v0.0.0-20210420182951-aeef2431dd9a
forge.chapril.org/armen/model v0.0.0-20210420183407-9aafd7a91b43
forge.chapril.org/armen/runner v0.0.0-20210420200355-aae17dcd1c71
forge.chapril.org/armen/workers v0.0.0-20210420200550-b0bb7a778ce8
forge.chapril.org/armen/workers v0.0.0-20210420222457-ca56600c0582
forge.chapril.org/mls-361/application v0.0.0-20210420182525-553553ee79fd
forge.chapril.org/mls-361/crypto v0.0.0-20210420182617-6b6e1d67ae49
forge.chapril.org/mls-361/errors v0.0.0-20210420182326-62f3fd4fd5e9

4
go.sum

@ -8,8 +8,8 @@ forge.chapril.org/armen/model v0.0.0-20210420183407-9aafd7a91b43 h1:thA5ZEYqvu0M
forge.chapril.org/armen/model v0.0.0-20210420183407-9aafd7a91b43/go.mod h1:phzQDpT4AAIDu13oNpPPVGNeVa6alMi+0OCPQ9YF5m4=
forge.chapril.org/armen/runner v0.0.0-20210420200355-aae17dcd1c71 h1:SJUSfIkQaPpo/c9+DSihnA79cWnqMhMEWCC2xsZOU7c=
forge.chapril.org/armen/runner v0.0.0-20210420200355-aae17dcd1c71/go.mod h1:pX8rNP1WOYlxF1sY7cef9yIUPtuP/k8QLL7A5anmSPA=
forge.chapril.org/armen/workers v0.0.0-20210420200550-b0bb7a778ce8 h1:6uO/T9zbGHniqQyGzulRgZDSpNDIdasza2jmGAhxhwM=
forge.chapril.org/armen/workers v0.0.0-20210420200550-b0bb7a778ce8/go.mod h1:LIWGF3+qhCUHeKyqjblKAKxvgSQJ8ud4fLR+WLKpdaU=
forge.chapril.org/armen/workers v0.0.0-20210420222457-ca56600c0582 h1:X4bQFvc9UHkDmF5IFCSc5Arld3k3mhBcX7NY/OG4j5Y=
forge.chapril.org/armen/workers v0.0.0-20210420222457-ca56600c0582/go.mod h1:LIWGF3+qhCUHeKyqjblKAKxvgSQJ8ud4fLR+WLKpdaU=
forge.chapril.org/mls-361/application v0.0.0-20210420182525-553553ee79fd h1:DS7paKa0kOu2tKZjAWRkhqtk49PsJJGYW4D1a2NRddU=
forge.chapril.org/mls-361/application v0.0.0-20210420182525-553553ee79fd/go.mod h1:x7iBnk1CanvvKBkI1H3CZ5juSu/cyLz1lLZI1OrmQFQ=
forge.chapril.org/mls-361/buffer v0.0.0-20210410182428-5dc7a7b2ae79 h1:Lh+y98uVFC7btl5FdxKNtokzHD2j14R4ZIgJECao6r4=

43
internal/demo/demo.go

@ -7,6 +7,8 @@
package demo
import (
"time"
"forge.chapril.org/armen/runner"
"forge.chapril.org/armen/workers"
@ -20,7 +22,33 @@ type demo struct {
var _demo *demo
func (d *demo) jt1(job *runner.Job) {
func (d *demo) panic(_ *runner.Job) {
panic("it's only a test") //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
func (d *demo) pending(job *runner.Job) {
v, ok := job.Private["key"]
if ok {
value, ok := v.(int)
if ok {
if value == 3 {
// end
return
}
job.SetPrivate("key", value+1)
} else {
job.Failed().SetError("bug")
}
} else {
job.SetPrivate("key", 0)
}
job.Pending().SetDuration(time.Second)
}
func (d *demo) succeeded(_ *runner.Job) {
// nothing to do
}
func Build(app components.Application, logger components.Logger, model components.Model) error {
@ -28,16 +56,25 @@ func Build(app components.Application, logger components.Logger, model component
return nil
}
if _, ok := app.LookupEnv("DEMO"); !ok {
if v, ok := app.LookupEnv("DEMO"); !ok || v != "t" && v != "true" {
return nil
}
d := &demo{
logger: logger,
}
r := runner.New("demo", model)
if err := r.AddJobHandler("jt1", runner.JHF(d.jt1)); err != nil {
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
}

Loading…
Cancel
Save