-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfoog.go
55 lines (43 loc) · 765 Bytes
/
foog.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
package foog
import (
"os"
"log"
"github.com/scgywx/foog/utils"
)
type handlerFunc func(*Context)
var (
nodeId int
router IRouter
logFile string
logLevel int
handlers map[string]handlerFunc
componentList []IComponent
)
func SetNodeId(id int){
nodeId = id
}
func SetRouter(r IRouter){
router = r
}
func SetLogLevel(level int){
logLevel = level
}
func SetLogFile(filename string){
logFile = filename
}
func Init(){
var err error
if err = initLog(); err != nil{
log.Println("init log error", err)
os.Exit(0)
}
if err = initComponent(); err != nil{
log.Println("init component error", err)
os.Exit(0)
}
utils.SetUUIDNode(nodeId)
}
func init(){
componentList = make([]IComponent, 0, 10)
handlers = make(map[string]handlerFunc)
}