Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring 2023 #72

Merged
merged 2 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ replace (

require (
go.osspkg.com/goppy/errors v0.1.0
go.osspkg.com/goppy/xtest v0.1.2
go.osspkg.com/goppy/xtest v0.1.3
)
20 changes: 12 additions & 8 deletions app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package app

import (
"go.osspkg.com/goppy/console"
"go.osspkg.com/goppy/iofile"
"go.osspkg.com/goppy/syscall"
"go.osspkg.com/goppy/xc"
"go.osspkg.com/goppy/xlog"
Expand All @@ -31,8 +32,8 @@ type (
pidfile string
configs Modules
modules Modules
sources Sources
packages *_dic
sources iofile.FileCodec
packages Container
logout *_log
log xlog.Logger
ctx xc.Context
Expand All @@ -46,7 +47,7 @@ func New() App {
return &_app{
modules: Modules{},
configs: Modules{},
packages: newDic(ctx),
packages: NewContainer(ctx),
ctx: ctx,
exitFunc: func(_ int) {},
}
Expand Down Expand Up @@ -104,7 +105,7 @@ func (a *_app) Run() {
},
{
Message: "Running dependencies",
Call: func() error { return a.packages.Build() },
Call: func() error { return a.packages.Start() },
},
},
func(er bool) {
Expand All @@ -118,7 +119,7 @@ func (a *_app) Run() {
[]step{
{
Message: "Stop dependencies",
Call: func() error { return a.packages.Down() },
Call: func() error { return a.packages.Stop() },
},
},
)
Expand All @@ -138,14 +139,17 @@ func (a *_app) Invoke(call interface{}) {
{
Call: func() error { return a.packages.Register(a.modules...) },
},
{
Call: func() error { return a.packages.Start() },
},
{
Call: func() error { return a.packages.Invoke(call) },
},
},
func(_ bool) {},
[]step{
{
Call: func() error { return a.packages.Down() },
Call: func() error { return a.packages.Stop() },
},
},
)
Expand All @@ -170,7 +174,7 @@ func (a *_app) prepareConfig(interactive bool) {
}
if len(a.cfile) > 0 {
// read config file
a.sources = Sources(a.cfile)
a.sources = iofile.FileCodec(a.cfile)

// init logger
config := &Config{}
Expand All @@ -191,7 +195,7 @@ func (a *_app) prepareConfig(interactive bool) {
)
// decode all configs
var configs []interface{}
configs, err = typingRefPtr(a.configs, func(i interface{}) error {
configs, err = typingReflectPtr(a.configs, func(i interface{}) error {
return a.sources.Decode(i)
})
if err != nil {
Expand Down
Loading