Browse Source

En cours de développement

master
losyme 7 months ago
parent
commit
506be0abf6
  1. 22
      LICENSE
  2. 10
      README.md
  3. 40
      Taskfile.yml
  4. 34
      cmd/main.go
  5. 27
      go.mod
  6. 38
      go.sum
  7. 78
      internal/application/application.go
  8. 26
      internal/application/cmdline.go
  9. 18
      internal/application/config.go
  10. 15
      internal/application/events.go
  11. 17
      internal/components/components.go

22
LICENSE

@ -1,9 +1,19 @@
MIT License
MIT License Copyright (c) 2021 losyme
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

10
README.md

@ -1,3 +1,11 @@
# dune
AFAIRE
A FAIRE.
## Licence
MIT.
---
Copyright (c) 2021 `losyme`.

40
Taskfile.yml

@ -0,0 +1,40 @@
## https://taskfile.dev
##---------------------
version: '3'
vars:
VERSION: 0.0.0
BUILTAT:
sh: date +%s
LDFLAGS: -s -w -X 'main._version={{.VERSION}}' -X 'main._builtAt={{.BUILTAT}}'
tasks:
update:
cmds:
- go get -u forge.chapril.org/losyme/application
- go get -u forge.chapril.org/losyme/cmdline
- go get -u forge.chapril.org/losyme/config
- go get -u forge.chapril.org/losyme/minikit
- go get -u forge.chapril.org/losyme/scheduler
- go mod tidy
lint:
cmds:
- golangci-lint run
test:
cmds:
- go test -cover -v ./...
build:
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o $GOPATH/bin/dune ./cmd/main.go
default:
cmds:
- task: lint
- task: test
- task: build
git:
cmds:
- git add .
- git commit -m "En cours de développement"
- git push

34
cmd/main.go

@ -0,0 +1,34 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package main
import (
"math/rand"
"os"
"time"
"forge.chapril.org/dune/dune/internal/application"
)
var (
_version string
_builtAt string
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func main() {
if err := application.New("dune", _version, _builtAt, os.Args[1:]).Run(); err != nil {
os.Exit(1)
}
}
/*
######################################################################################################## @(°_°)@ #######
*/

27
go.mod

@ -0,0 +1,27 @@
module forge.chapril.org/dune/dune
go 1.17
require (
forge.chapril.org/losyme/application v0.0.0-20211008200819-b014e639a171
forge.chapril.org/losyme/cmdline v0.0.0-20211003204532-02afa7010d2c
forge.chapril.org/losyme/config v0.0.0-20211005163519-b38ce8696276
forge.chapril.org/losyme/minikit v0.0.0-20211008201136-18ab96793bc6
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf
github.com/gorilla/mux v1.8.0
)
require (
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518 // indirect
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720 // indirect
forge.chapril.org/losyme/dune v0.0.0-20211003204645-53703190a1b3 // indirect
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40 // indirect
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae // indirect
forge.chapril.org/losyme/logger v0.0.0-20211005171545-68273525f4af // indirect
forge.chapril.org/losyme/util v0.0.0-20210914170439-20572e6207bf // indirect
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

38
go.sum

@ -0,0 +1,38 @@
forge.chapril.org/losyme/application v0.0.0-20211008200819-b014e639a171 h1:T8MQXGNCs1AsjtIQMYw1gjp0g4H9Frflosm6kkY8e7g=
forge.chapril.org/losyme/application v0.0.0-20211008200819-b014e639a171/go.mod h1:olQo5n5tnBRHq0wcc0lNbymvsXdTuYaCjNfd2d/+01w=
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518 h1:B7wu0DWUwpt0Mw/VTuWQZikhV/VD6kc2iJWbIY+jgEM=
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518/go.mod h1:4Yl585hmF3bWZfuwGF2Ym8ErykJZiF9yawlmK7szIkc=
forge.chapril.org/losyme/cmdline v0.0.0-20211003204532-02afa7010d2c h1:vuxjciZZRmFU3uvgeEg1hV0KgSDvJ2HrJjBclvKiYkM=
forge.chapril.org/losyme/cmdline v0.0.0-20211003204532-02afa7010d2c/go.mod h1:PUgDd5JoQrqKocbor0CK73nbGQ0/4SNCVb2w++ik0xA=
forge.chapril.org/losyme/config v0.0.0-20211005163519-b38ce8696276 h1:xmdFs2aJdkL2RAHS3jhmHpXvXjyhiEoyFR8RPInxp80=
forge.chapril.org/losyme/config v0.0.0-20211005163519-b38ce8696276/go.mod h1:Oacy9PnlGYriSyqQW5dgo4vQMBlu5lW77kUssmc491U=
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720 h1:tMwzjPmGvBb5/5Cx0OIPKqT9zMMR6gQn6398rwT0ghc=
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720/go.mod h1:zSawWghP8cyqaQNOtKBAWGfAeR93uAyHMqpaXtZJsF8=
forge.chapril.org/losyme/dune v0.0.0-20211003204645-53703190a1b3 h1:mVMwpyuzXv5+/5lIbX7WwTbO8RVek/gFFJHSp44tvS0=
forge.chapril.org/losyme/dune v0.0.0-20211003204645-53703190a1b3/go.mod h1:QheUQV1zNMzW1RSnVyuTqn0VVS/mgtz7FfMdY7ekvao=
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40 h1:EoVVFHoIsWRlecHmXP4kx3ALchz5DAfNwso3gcl/Jbk=
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40/go.mod h1:saYfIRBW9zjiCik+/+5ZaajMEnTPBNI00lF9EnO+2kM=
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-20211005171545-68273525f4af h1:Eun7tisbfRh2vUA6tfn2wlpYjbla8LElilEBUNSp8p8=
forge.chapril.org/losyme/logger v0.0.0-20211005171545-68273525f4af/go.mod h1:a3fN8yTjq5S/ramr03hIkutKM/35UsijUgRNKHjjlMU=
forge.chapril.org/losyme/minikit v0.0.0-20211008201136-18ab96793bc6 h1:u+js7AAw6hyQasmu3ZjmmQgs8R1jv/vn71Hgq3W7xi0=
forge.chapril.org/losyme/minikit v0.0.0-20211008201136-18ab96793bc6/go.mod h1:tFzl5+8oJAWFHwK7O8KRtd9aDBPVDKmdB0ZRt1KmC1w=
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-20210914170439-20572e6207bf h1:JZQLbcldf8q/o5OjaYlcNCX/dA1oshGnY6YM2VidAtI=
forge.chapril.org/losyme/util v0.0.0-20210914170439-20572e6207bf/go.mod h1:lKYvkuBOTU3E2HuQZDh4ZSA4u3VcFopQbdPUKaHGHEk=
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034 h1:4NMOPXxwRiXS7wltj2ZZmMO1nFRMPmG1dXK4Ta4MtiM=
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034/go.mod h1:AgvbvGzTkQkbiM+s9eVhvLUSHbA0V6N+q5oBFI2v0LA=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo=
github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

78
internal/application/application.go

@ -0,0 +1,78 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package application
import (
"forge.chapril.org/losyme/application"
"forge.chapril.org/losyme/minikit"
"github.com/gorilla/mux"
"forge.chapril.org/dune/dune/internal/components"
)
type clFlags struct {
demo bool
}
type Application struct {
minikit *minikit.Kit
components *components.Components
clFlags *clFlags
router *mux.Router
}
func New(name, version, builtAt string, args []string) *Application {
app := &Application{
clFlags: &clFlags{},
router: mux.NewRouter(),
}
kit := minikit.New(&minikit.Config{
Application: application.New(name, version, builtAt, "job and workflow management server"),
Components: []string{
"cmdline",
"config",
"crypto",
"logger",
"scheduler",
"server",
},
CmdLineArgs: args,
CmdLineInit: app.cmdlineInitialize,
ConfigInit: app.configInitialize,
SchedulerCb: app.messageHandler,
ServerHandler: app.router,
})
app.minikit = kit
cs := &components.Components{
Components: kit.Components,
}
app.components = cs
return app
}
func (app *Application) run() error {
defer func() {
if logger := app.components.Logger; logger != nil {
logger.Close()
}
}()
return app.minikit.Build()
}
func (app *Application) Run() error {
return app.components.Application.OnError(app.run()) //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
}
/*
######################################################################################################## @(°_°)@ #######
*/

26
internal/application/cmdline.go

@ -0,0 +1,26 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package application
import "forge.chapril.org/losyme/cmdline"
func (app *Application) cmdlineInitialize() []*cmdline.Cmd {
clf := app.clFlags
cmdSetup := &cmdline.Cmd{
Name: "setup",
Usage: "application setup",
}
cmdSetup.BoolFlag(&clf.demo, "demo", false, "demonstration mode")
return []*cmdline.Cmd{cmdSetup}
}
/*
######################################################################################################## @(°_°)@ #######
*/

18
internal/application/config.go

@ -0,0 +1,18 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package application
import "forge.chapril.org/losyme/config"
func (app *Application) configInitialize(cfg *config.Config) {
cfg.Set("trace", "logger", "level")
cfg.Set([]string{"stderr"}, "logger", "outputs")
}
/*
######################################################################################################## @(°_°)@ #######
*/

15
internal/application/events.go

@ -0,0 +1,15 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package application
import "forge.chapril.org/losyme/scheduler"
func (app *Application) messageHandler(_ *scheduler.Message) {}
/*
######################################################################################################## @(°_°)@ #######
*/

17
internal/components/components.go

@ -0,0 +1,17 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### dune ####### Copyright (c) 2021 losyme ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package components
import "forge.chapril.org/losyme/minikit/pkg/components"
type Components struct {
*components.Components
}
/*
######################################################################################################## @(°_°)@ #######
*/
Loading…
Cancel
Save