Browse Source

En cours de développement

master
mls-361 5 months ago
parent
commit
5662b87324
  1. 2
      Taskfile.yml
  2. 9
      cmd/main.go
  3. 2
      go.mod
  4. 6
      go.sum
  5. 83
      internal/demo/demo.go

2
Taskfile.yml

@ -15,6 +15,8 @@ tasks:
- go get -u forge.chapril.org/armen/jw
- go get -u forge.chapril.org/armen/memory
- go get -u forge.chapril.org/armen/model
- go get -u forge.chapril.org/armen/runner
- go get -u forge.chapril.org/armen/workers
- go get -u forge.chapril.org/mls-361/application
- go get -u forge.chapril.org/mls-361/crypto
- go get -u forge.chapril.org/mls-361/errors

9
cmd/main.go

@ -21,6 +21,7 @@ import (
"forge.chapril.org/armen/armen/internal/components"
"forge.chapril.org/armen/armen/internal/config"
"forge.chapril.org/armen/armen/internal/crypto"
"forge.chapril.org/armen/armen/internal/demo"
"forge.chapril.org/armen/armen/internal/logger"
"forge.chapril.org/armen/armen/internal/model"
"forge.chapril.org/armen/armen/internal/router"
@ -59,6 +60,10 @@ func createComponents(app components.Application) (components.Logger, components
return nil, nil, errors.WithMessage(err, "model") //////////////////////////////////////////////////////////////
}
if err := demo.Build(app, logger, model); err != nil {
return nil, nil, errors.WithMessage(err, "demo") ///////////////////////////////////////////////////////////////
}
router := router.Build(logger)
server, err := server.Build(config, logger, router)
@ -118,10 +123,14 @@ func run() error {
group, endCh := waitEnd(server)
demo.Start()
err = server.Start()
close(endCh)
demo.Stop()
group.Wait()
logger.Info( //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

2
go.mod

@ -6,6 +6,8 @@ require (
forge.chapril.org/armen/jw v0.0.0-20210420182827-e84586d52e7d
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/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

6
go.sum

@ -1,9 +1,15 @@
forge.chapril.org/armen/factory v0.0.0-20210420185548-4a8d6eee6f1a h1:3akLeqhwfmdQ6s+LK5nwDzhoQqYULnS6Yu3bhZJLAZE=
forge.chapril.org/armen/factory v0.0.0-20210420185548-4a8d6eee6f1a/go.mod h1:8X6DFD/KePInb+qxq8fj19QLmvgJnRW6SGZS9OAXh1o=
forge.chapril.org/armen/jw v0.0.0-20210420182827-e84586d52e7d h1:xtGaldnHe8gRdCRVR+tG6kYkklErNcnuJjldjijVkfU=
forge.chapril.org/armen/jw v0.0.0-20210420182827-e84586d52e7d/go.mod h1:/493TkL40h/dcYibnL1dPOKD1sgLoChgLyQ8BiLPr6g=
forge.chapril.org/armen/memory v0.0.0-20210420182951-aeef2431dd9a h1:a2JaoORflqK97IYY0lhO4T+SsWnCVXcxgXb/Z9QmR80=
forge.chapril.org/armen/memory v0.0.0-20210420182951-aeef2431dd9a/go.mod h1:WHra3zbTsXiivHF1e7rmMFWvUOLYQuoaMG+VysjpG1A=
forge.chapril.org/armen/model v0.0.0-20210420183407-9aafd7a91b43 h1:thA5ZEYqvu0MMHgQ88aWUdIAo4FhEgoYNfeUzMzq0GQ=
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/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=

83
internal/demo/demo.go

@ -0,0 +1,83 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### 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()
}
/*
######################################################################################################## @(°_°)@ #######
*/
Loading…
Cancel
Save