forked from mesos/mr-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Initialize.go
35 lines (28 loc) · 849 Bytes
/
Initialize.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
package types
import (
"container/list"
"log"
"github.com/mesos/mr-redis/common/store/etcd"
)
//Initialize Initialize all the data strucutres in common package, should be called by the main program only and should be called only once per program
func Initialize(dbtype string, config string) (bool, error) {
//Initalize all the communication channels
OfferList = list.New()
OfferList.Init()
Cchan = make(chan TaskCreate)
Mchan = make(chan *TaskUpdate) //Channel for Maintainer
Dchan = make(chan TaskMsg) //Channel for Destroyer
//Initalize the Internal in-memory storage
MemDb = NewInMem()
//Initalize the store db
switch dbtype {
case "etcd":
Gdb = etcd.New()
err := Gdb.Setup(config)
if err != nil {
log.Fatalf("Failed to setup etcd database error:%v", err)
}
return Gdb.IsSetup(), nil
}
return true, nil
}