Browse Source

En cours de développement

master
losyme 6 months ago
parent
commit
fb9ea61906
  1. 4
      go.mod
  2. 8
      go.sum
  3. 2
      internal/application/api.go
  4. 3
      internal/application/application.go
  5. 40
      internal/application/demo.go
  6. 4
      internal/application/model.go
  7. 6
      internal/application/storage.go
  8. 2
      internal/components/components.go
  9. 44
      internal/demo/demo.go
  10. 37
      internal/demo/logger.go

4
go.mod

@ -10,8 +10,8 @@ require (
forge.chapril.org/losyme/config v0.0.0-20211025142334-51a8a7a73a4f
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40
forge.chapril.org/losyme/kong v0.0.0-20211102220824-8f8a63ae4cca
forge.chapril.org/losyme/logger v0.0.0-20211114152309-4801f8e79676
forge.chapril.org/losyme/minikit v0.0.0-20211119190218-ee650b4675c1
forge.chapril.org/losyme/logger v0.0.0-20211119225711-ee831caaf5d4
forge.chapril.org/losyme/minikit v0.0.0-20211119225931-4f3e0dcabbb7
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034
)

8
go.sum

@ -18,10 +18,10 @@ forge.chapril.org/losyme/kong v0.0.0-20211102220824-8f8a63ae4cca h1:VyGatlviG2GA
forge.chapril.org/losyme/kong v0.0.0-20211102220824-8f8a63ae4cca/go.mod h1:sOhHc+IcV5vGNnygTML5/P7Ftmlsf9UB2oL+HQRpsYw=
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae h1:RdYWXKy+OQNJueb4Qqqo7sL4OY3/TpfUvmoIoH8ua9E=
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae/go.mod h1:wnVjwnCO2vFLLZ1EgFuFws1n8XLluufsGsdozGYSA7c=
forge.chapril.org/losyme/logger v0.0.0-20211114152309-4801f8e79676 h1:XGc8rZ/hTW9/mUUAJ7nVtmrqnxeKQFKGs3NO+tnIfgY=
forge.chapril.org/losyme/logger v0.0.0-20211114152309-4801f8e79676/go.mod h1:a3fN8yTjq5S/ramr03hIkutKM/35UsijUgRNKHjjlMU=
forge.chapril.org/losyme/minikit v0.0.0-20211119190218-ee650b4675c1 h1:DWQZQM6gTEIv7EmPwsJJ5FAx1SWDtKaJe8hukwfQF90=
forge.chapril.org/losyme/minikit v0.0.0-20211119190218-ee650b4675c1/go.mod h1:X8a2/jwJ5wuoPAK776Ci3KZbK3151M4FHvlrXEiFl4k=
forge.chapril.org/losyme/logger v0.0.0-20211119225711-ee831caaf5d4 h1:+5xllpRoYR2wNkBd5FSACEcf7ZSDk6Nm4Y/qFSCvISE=
forge.chapril.org/losyme/logger v0.0.0-20211119225711-ee831caaf5d4/go.mod h1:a3fN8yTjq5S/ramr03hIkutKM/35UsijUgRNKHjjlMU=
forge.chapril.org/losyme/minikit v0.0.0-20211119225931-4f3e0dcabbb7 h1:SNYC9D1fVMOi70shN8XT0PUp0jyR+/9r59ncZV8JTO8=
forge.chapril.org/losyme/minikit v0.0.0-20211119225931-4f3e0dcabbb7/go.mod h1:NdJux6DVhfHaiK+QAc2FV0/fFreh7gMrnuFgySH4Y0s=
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf h1:5OIlwVBTdvjCXh2JHAh5rq8FgSe1lXuuKDFtO/ZRaRM=
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf/go.mod h1:VNjFKl0Q2vvLDnR9tdNdTIZDLQNlR+gcIGNf2aIYv3o=
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe h1:xjMUKHxtG8jz57JyOxgNLlRaPLJeQvMV9K3HNlhKDB8=

2
internal/application/api.go

@ -15,7 +15,7 @@ import (
func (app *Application) API() error {
cs := app.components
logger, err := cs.Logger.NewComponent(uuid.New(), "api")
logger, err := cs.Logger.Clone(uuid.New(), "api")
if err != nil {
return err
}

3
internal/application/application.go

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

40
internal/application/demo.go

@ -6,47 +6,17 @@
package application
import (
"forge.chapril.org/dune/sdk/runner"
"forge.chapril.org/dune/sdk/workers"
"forge.chapril.org/losyme/minikit/pkg/components"
)
import "forge.chapril.org/dune/dune/internal/demo"
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
}
func (app *Application) demo() error {
cs := app.components
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)
c, err := demo.New(cs.Application.Name(), cs.Logger.Component, cs.Model)
if err != nil {
return err
}
app.demo = &demo{
workers: workers,
}
cs.Demo = c
return nil
}

4
internal/application/model.go

@ -15,7 +15,7 @@ import (
func (app *Application) model() error {
cs := app.components
logger, err := cs.Logger.NewComponent(uuid.New(), "model")
logger, err := cs.Logger.Clone(uuid.New(), "model")
if err != nil {
return err
}
@ -30,7 +30,7 @@ func (app *Application) model() error {
return err
}
app.components.Model = c
cs.Model = c
return nil
}

6
internal/application/storage.go

@ -13,14 +13,16 @@ import (
)
func (app *Application) storage() error {
impl, err := app.components.Config.GetString("storage")
cs := app.components
impl, err := cs.Config.GetString("storage")
if err != nil {
return err
}
switch impl {
case "memory":
app.components.Storage = memory.New()
cs.Storage = memory.New()
return nil
default:
return errors.New( /////////////////////////////////////////////////////////////////////////////////////////////

2
internal/components/components.go

@ -11,12 +11,14 @@ import (
"forge.chapril.org/losyme/minikit/pkg/components"
"forge.chapril.org/dune/dune/internal/api"
"forge.chapril.org/dune/dune/internal/demo"
"forge.chapril.org/dune/dune/internal/model"
)
type Components struct {
*components.Components
API *api.API
Demo *demo.Demo
Model *model.Model
Storage jw.Storage
}

44
internal/demo/demo.go

@ -0,0 +1,44 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### 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.Workers
}
func New(namespace string, logger *logger.Component, model runner.Model) (*Demo, error) {
runner := runner.New(namespace, model)
cfg := &workers.Config{
PoolSize: _workerPoolSize,
Runner: runner,
Logger: newWorkersLogger(logger),
}
workers, err := workers.New(cfg)
if err != nil {
return nil, err
}
demo := &Demo{
workers: workers,
}
return demo, nil
}
/*
######################################################################################################## @(°_°)@ #######
*/

37
internal/demo/logger.go

@ -0,0 +1,37 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package demo
import (
"forge.chapril.org/dune/sdk/workers"
"forge.chapril.org/losyme/logger"
)
type workersLogger struct {
*logger.Component
}
func newWorkersLogger(logger *logger.Component) *workersLogger {
return &workersLogger{
Component: logger,
}
}
func (wl *workersLogger) Clone(id, name string) (workers.Logger, error) {
logger, err := wl.Component.Clone(id, name)
if err != nil {
return nil, err
}
clone := newWorkersLogger(logger)
return clone, nil
}
/*
######################################################################################################## @(°_°)@ #######
*/
Loading…
Cancel
Save