Skip to content

Commit 456e695

Browse files
committed
make app fields private
1 parent 958347d commit 456e695

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

internal/app/app.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@ import (
1717
// App integrates the modules to serve.
1818
type App struct {
1919
context context.Context
20-
Config *config.Config
21-
Logger *logger.Logger
20+
config *config.Config
21+
logger *logger.Logger
2222
S3 *s3.S3
23-
HttpServer *httpServer.Server
24-
Database *database.Database
25-
Container *container.Container
23+
httpServer *httpServer.Server
24+
database *database.Database
25+
container *container.Container
2626
}
2727

2828
// New creates an app from the given configuration file.
2929
func New(configPath string) (a *App, err error) {
3030
a = &App{}
3131

32-
a.Config, err = config.New(configPath)
32+
a.config, err = config.New(configPath)
3333
if err != nil {
3434
return nil, err
3535
}
36-
a.Logger, err = logger.New(a.Config, a.ShutdownModules)
36+
a.logger, err = logger.New(a.config, a.ShutdownModules)
3737
if err != nil {
3838
return nil, err
3939
}
40-
a.Logger.Debug("app: config & logger initialized")
40+
a.logger.Debug("app: config & logger initialized")
4141

42-
a.Database = database.New(a.Config, a.Logger)
43-
a.S3 = s3.New(a.Config, a.Logger)
44-
a.Container = container.New(a.Database, a.S3)
45-
a.HttpServer = httpServer.New(a.Config, a.Logger, a.Container)
42+
a.database = database.New(a.config, a.logger)
43+
a.S3 = s3.New(a.config, a.logger)
44+
a.container = container.New(a.database, a.S3)
45+
a.httpServer = httpServer.New(a.config, a.logger, a.container)
4646

47-
a.Logger.Debug("app: application modules initialized")
47+
a.logger.Debug("app: application modules initialized")
4848

4949
a.setupSignalListener()
5050

@@ -53,9 +53,9 @@ func New(configPath string) (a *App, err error) {
5353

5454
// Boot makes sure the critical modules and external sources work fine.
5555
func (a *App) Boot() {
56-
a.Database.Init()
56+
a.database.Init()
5757
a.S3.Init()
58-
a.HttpServer.Serve()
58+
a.httpServer.Serve()
5959
}
6060

6161
// setupSignalListener sets up a listener to exit signals from os and closes the app gracefully.
@@ -68,17 +68,17 @@ func (a *App) setupSignalListener() {
6868

6969
go func() {
7070
s := <-signalChannel
71-
a.Logger.Info("app: system call", zap.String("signal", s.String()))
71+
a.logger.Info("app: system call", zap.String("signal", s.String()))
7272
cancel()
7373
}()
7474
}
7575

7676
func (a *App) ShutdownModules() {
77-
if a.HttpServer != nil {
78-
a.HttpServer.Close()
77+
if a.httpServer != nil {
78+
a.httpServer.Close()
7979
}
80-
if a.Database != nil {
81-
a.Database.Close()
80+
if a.database != nil {
81+
a.database.Close()
8282
}
8383
}
8484

@@ -88,7 +88,7 @@ func (a *App) Wait() {
8888

8989
a.ShutdownModules()
9090

91-
if a.Logger != nil {
92-
a.Logger.Close()
91+
if a.logger != nil {
92+
a.logger.Close()
9393
}
9494
}

0 commit comments

Comments
 (0)