forked from gogap/spirit
/
runtime_config.go
61 lines (50 loc) · 1.63 KB
/
runtime_config.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
package spirit
import (
"github.com/gogap/env_json"
)
type runComponentConf struct {
Name string `json:"name"`
Address []addressConf `json:"address,omitempty"`
PortHooks []portHookConf `json:"port_hooks,omitempty"`
}
type addressConf struct {
PortName string `json:"port_name"`
HandlerName string `json:"handler_name"`
Type string `json:"type"`
Url string `json:"url"`
Options map[string]interface{} `json:"options"`
}
type heartbeatConf struct {
Heart string `json:"heart"`
Interval int64 `json:"interval"`
Options map[string]interface{} `json:"options"`
}
type portHookConf struct {
Type string `json:"type"`
Name string `json:"name"`
Port string `json:"port_name"`
Options map[string]interface{} `json:"options"`
}
type globalHookConf struct {
Type string `json:"type"`
Name string `json:"name"`
Options map[string]interface{} `json:"options"`
}
type AssetProperty struct {
FileName string `json:"file"`
NeedBuild bool `json:"env_build"`
}
type runtimeConfig struct {
Components []runComponentConf `json:"components"`
Heartbeat []heartbeatConf `json:"heartbeat,omitempty"`
GlobalHooks []globalHookConf `json:"global_hooks,omitempty"`
Assets []AssetProperty `json:"assets,omitempty"`
}
func (p *runtimeConfig) Serialize() (str string, err error) {
var data []byte
if data, err = env_json.MarshalIndent(p, "", " "); err != nil {
return
}
str = string(data)
return
}