Client build scripts fixes and server stub with local devzone.
All checks were successful
Linting and tests / Linting (push) Successful in 6s
All checks were successful
Linting and tests / Linting (push) Successful in 6s
This commit is contained in:
@@ -9,7 +9,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"bunker/commons"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -19,6 +22,8 @@ var (
|
||||
|
||||
// Application is a lifecycle controlling structure for application.
|
||||
type Application struct {
|
||||
ctx context.Context
|
||||
cancelFunc context.CancelFunc
|
||||
fyneApp fyne.App
|
||||
baseLogger *slog.Logger
|
||||
appLogger *slog.Logger
|
||||
@@ -96,7 +101,7 @@ func (a *Application) connectDependencies() error {
|
||||
|
||||
// ContextWithTimeout returns context.Context with requested timeout.
|
||||
func (a *Application) ContextWithTimeout(timeout time.Duration) context.Context {
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), timeout)
|
||||
ctx, cancelFunc := context.WithTimeout(a.ctx, timeout)
|
||||
|
||||
// As we do not need to call cancelFunc - make linter happy.
|
||||
// This probably will lead to context leak, so it should be investigated.
|
||||
@@ -106,11 +111,13 @@ func (a *Application) ContextWithTimeout(timeout time.Duration) context.Context
|
||||
}
|
||||
|
||||
func (a *Application) initialize() {
|
||||
a.ctx, a.cancelFunc = context.WithCancel(context.Background())
|
||||
|
||||
a.initializeLogger()
|
||||
|
||||
a.services = make([]Service, 0)
|
||||
a.fyneApp = app.NewWithID(commons.ClientAppID)
|
||||
|
||||
a.initializeFyne()
|
||||
a.services = make([]Service, 0)
|
||||
}
|
||||
|
||||
func (a *Application) launchStartupTasks() error {
|
||||
@@ -167,7 +174,6 @@ func (a *Application) launchStartupTasks() error {
|
||||
func (a *Application) Shutdown() error {
|
||||
a.appLogger.Info("Stopping pztrn's Bunker...")
|
||||
|
||||
// Сначала тушим фичи.
|
||||
for _, service := range a.services {
|
||||
if !strings.Contains(service.Name(), "features/") {
|
||||
continue
|
||||
@@ -180,7 +186,6 @@ func (a *Application) Shutdown() error {
|
||||
}
|
||||
}
|
||||
|
||||
// Потом тушим ядро.
|
||||
for _, service := range a.services {
|
||||
if !strings.Contains(service.Name(), "core/") {
|
||||
continue
|
||||
@@ -198,7 +203,7 @@ func (a *Application) Shutdown() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start запускает приложение.
|
||||
// Start starts application.
|
||||
func (a *Application) Start() error {
|
||||
if err := a.connectDependencies(); err != nil {
|
||||
return fmt.Errorf("%w: %w", errApplication, err)
|
||||
|
Reference in New Issue
Block a user