@@ -17,34 +17,34 @@ import (
17
17
// App integrates the modules to serve.
18
18
type App struct {
19
19
context context.Context
20
- Config * config.Config
21
- Logger * logger.Logger
20
+ config * config.Config
21
+ logger * logger.Logger
22
22
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
26
26
}
27
27
28
28
// New creates an app from the given configuration file.
29
29
func New (configPath string ) (a * App , err error ) {
30
30
a = & App {}
31
31
32
- a .Config , err = config .New (configPath )
32
+ a .config , err = config .New (configPath )
33
33
if err != nil {
34
34
return nil , err
35
35
}
36
- a .Logger , err = logger .New (a .Config , a .ShutdownModules )
36
+ a .logger , err = logger .New (a .config , a .ShutdownModules )
37
37
if err != nil {
38
38
return nil , err
39
39
}
40
- a .Logger .Debug ("app: config & logger initialized" )
40
+ a .logger .Debug ("app: config & logger initialized" )
41
41
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 )
46
46
47
- a .Logger .Debug ("app: application modules initialized" )
47
+ a .logger .Debug ("app: application modules initialized" )
48
48
49
49
a .setupSignalListener ()
50
50
@@ -53,9 +53,9 @@ func New(configPath string) (a *App, err error) {
53
53
54
54
// Boot makes sure the critical modules and external sources work fine.
55
55
func (a * App ) Boot () {
56
- a .Database .Init ()
56
+ a .database .Init ()
57
57
a .S3 .Init ()
58
- a .HttpServer .Serve ()
58
+ a .httpServer .Serve ()
59
59
}
60
60
61
61
// setupSignalListener sets up a listener to exit signals from os and closes the app gracefully.
@@ -68,17 +68,17 @@ func (a *App) setupSignalListener() {
68
68
69
69
go func () {
70
70
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 ()))
72
72
cancel ()
73
73
}()
74
74
}
75
75
76
76
func (a * App ) ShutdownModules () {
77
- if a .HttpServer != nil {
78
- a .HttpServer .Close ()
77
+ if a .httpServer != nil {
78
+ a .httpServer .Close ()
79
79
}
80
- if a .Database != nil {
81
- a .Database .Close ()
80
+ if a .database != nil {
81
+ a .database .Close ()
82
82
}
83
83
}
84
84
@@ -88,7 +88,7 @@ func (a *App) Wait() {
88
88
89
89
a .ShutdownModules ()
90
90
91
- if a .Logger != nil {
92
- a .Logger .Close ()
91
+ if a .logger != nil {
92
+ a .logger .Close ()
93
93
}
94
94
}
0 commit comments