/
app.go
70 lines (60 loc) · 1.52 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package app
import (
"github.com/goatcms/goatcore/filesystem"
)
// Module represent a app module
type Module interface {
InitDependencies(App) error
RegisterDependencies(App) error
Run(App) error
}
// Bootstrap represent bootstrap of a app
type Bootstrap interface {
Init() error
Register(Module) error
Run() error
}
// Bootstrap represent bootstrap of a app
type Version interface {
Major() int
Minor() int
Path() int
Suffix() string
String() string
}
// App represent a app
type App interface {
Injector
AppHealthCheckers
Arguments() []string
DependencyProvider() DependencyProvider
Filespaces() AppFilespaces
IOContext() IOContext
Name() string
Scopes() AppScopes
Terminal() TerminalManager
Version() Version
}
type AppScopes interface {
App() Scope
Arguments() DataScope
Config() DataScope
Filespace() DataScope
}
type AppFilespaces interface {
CWD() filesystem.Filespace
Home() filesystem.Filespace
Root() filesystem.Filespace
Tmp() filesystem.Filespace
}
// HealthCheckerCallback is function to check application health
type HealthCheckerCallback func(App, Scope) (msg string, err error)
// AppHealthCheckers check application helth
type AppHealthCheckers interface {
// HealthCheckerNames return HealthChecker's names
HealthCheckerNames() []string
// HealthChecker return an HealthChecker by name
HealthChecker(name string) HealthCheckerCallback
// SetHealthChecker set new health hecker. Panic if healthecker name is duplicated
SetHealthChecker(name string, cb HealthCheckerCallback) (err error)
}