Browse Source

En cours de développement

master
losyme 2 months ago
parent
commit
5122c94033
  1. 1
      Taskfile.yml
  2. 1
      go.mod
  3. 2
      go.sum
  4. 3
      internal/application/application.go
  5. 10
      internal/application/cmdline.go
  6. 43
      internal/application/demo.go

1
Taskfile.yml

@ -14,6 +14,7 @@ tasks:
update:
cmds:
- go get -u forge.chapril.org/dune/jw
- go get -u forge.chapril.org/dune/sdk
- go get -u forge.chapril.org/losyme/application
- go get -u forge.chapril.org/losyme/cmdline
- go get -u forge.chapril.org/losyme/config

1
go.mod

@ -4,6 +4,7 @@ go 1.17
require (
forge.chapril.org/dune/jw v0.0.0-20211114170701-4b66b0d705ea
forge.chapril.org/dune/sdk v0.0.0-20211119180115-f339659ec029
forge.chapril.org/losyme/application v0.0.0-20211029102910-b7db6effc015
forge.chapril.org/losyme/cmdline v0.0.0-20211029192907-e6f74788c44f
forge.chapril.org/losyme/config v0.0.0-20211025142334-51a8a7a73a4f

2
go.sum

@ -1,5 +1,7 @@
forge.chapril.org/dune/jw v0.0.0-20211114170701-4b66b0d705ea h1:EC1XXrDQ6E7Oed04iZFKsk2dbxJORBH2G+UxBFz42j4=
forge.chapril.org/dune/jw v0.0.0-20211114170701-4b66b0d705ea/go.mod h1:7CyK2ZvzHntSlOZ7kWcqVhkmUzlE0QI3uKW9kPbNbOY=
forge.chapril.org/dune/sdk v0.0.0-20211119180115-f339659ec029 h1:LPzlsg367WrDwdoJHhUEWlQCraT/Ncx8hj2bQgwUjak=
forge.chapril.org/dune/sdk v0.0.0-20211119180115-f339659ec029/go.mod h1:MoElZHMrmoc+AH8OXwduGLF+1ls73nS/+3JGx7K8ta4=
forge.chapril.org/losyme/application v0.0.0-20211029102910-b7db6effc015 h1:mZQ2kC2ucXI0lNRVyIOVEz3zu0ChOQ9wTPG0W69fI1Y=
forge.chapril.org/losyme/application v0.0.0-20211029102910-b7db6effc015/go.mod h1:olQo5n5tnBRHq0wcc0lNbymvsXdTuYaCjNfd2d/+01w=
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518 h1:B7wu0DWUwpt0Mw/VTuWQZikhV/VD6kc2iJWbIY+jgEM=

3
internal/application/application.go

@ -17,6 +17,7 @@ type Application struct {
minikit *minikit.Kit
components *components.Components
cmdLine *cmdLine
demo *demo
}
func New(name, version, builtAt string, args []string) *Application {
@ -72,7 +73,7 @@ func (app *Application) Run() error {
}
if app.cmdLine.demo {
if err := app.demo(); err != nil {
if err := app.setupDemo(); err != nil {
return err
}
}

10
internal/application/cmdline.go

@ -17,6 +17,8 @@ type cmdLine struct {
func (app *Application) cmdlineInitialize(c *cmdline.CmdLine) {
cl := app.cmdLine
c.BoolFlag(&cl.demo, "demo", false, "demonstration mode")
cmdDecrypt := cmdline.NewCmd(
"decrypt",
"decrypt string",
@ -39,16 +41,8 @@ func (app *Application) cmdlineInitialize(c *cmdline.CmdLine) {
cmdEncrypt.StringFlag(&cl.strValue, "string", "", "string to encrypt")
cmdSetup := cmdline.NewCmd(
"setup",
"application setup",
)
cmdSetup.BoolFlag(&cl.demo, "demo", false, "demonstration mode")
c.AddCmd(cmdDecrypt)
c.AddCmd(cmdEncrypt)
c.AddCmd(cmdSetup)
}
/*

43
internal/application/demo.go

@ -6,7 +6,48 @@
package application
func (app *Application) demo() error {
import (
"forge.chapril.org/dune/sdk/runner"
"forge.chapril.org/dune/sdk/workers"
"forge.chapril.org/losyme/minikit/pkg/components"
)
type demoLogger struct {
*components.Logger
}
func newDemoLogger(logger *components.Logger) *demoLogger {
return &demoLogger{
Logger: logger,
}
}
func (dl *demoLogger) Clone(id, name string) (workers.Logger, error) {
return nil, nil
}
type demo struct {
workers *workers.Workers
}
func (app *Application) setupDemo() error {
runner := runner.New(app.components.Application.Name(), app.components.Model)
cfg := &workers.Config{
PoolSize: 2,
Runner: runner,
Logger: newDemoLogger(app.components.Logger),
}
workers, err := workers.New(cfg)
if err != nil {
return err
}
app.demo = &demo{
workers: workers,
}
return nil
}

Loading…
Cancel
Save