Skip to content

Commit

Permalink
Change mongo state
Browse files Browse the repository at this point in the history
  • Loading branch information
vassilux committed Oct 14, 2014
1 parent 07a41b5 commit debbb95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
3 changes: 1 addition & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"asteriskPassword": "lepanos",
"testCallSchedule": 20,
"notifications": [
"f1com",
"smtp"
"f1com"
],
"dialplanContext": [
{ "name": "app-out", "direction": 1},
Expand Down
28 changes: 14 additions & 14 deletions evwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const (
APPSTO = 2
MYSQKO = 3
MYSQOK = 4
MONGOKO = 5
MONGOOK = 6
MONGKO = 5
MONGOK = 6
TCALOK = 7
TCALKO = 8
CCALOK = 9 // check call action success
Expand Down Expand Up @@ -82,8 +82,8 @@ func NewEventWatcher(config *Config) (ew *EventWatcher) {
ew.eventsMask.Set(APPSTO)
ew.eventsMask.Set(MYSQKO)
ew.eventsMask.Set(MYSQOK)
ew.eventsMask.Set(MONGOKO)
ew.eventsMask.Set(MONGOOK)
ew.eventsMask.Set(MONGKO)
ew.eventsMask.Set(MONGOK)
ew.eventsMask.Set(TCALKO)
ew.eventsMask.Set(TCALOK)
ew.eventsMask.Set(CCALOK)
Expand Down Expand Up @@ -145,22 +145,22 @@ func (eventWatcher *EventWatcher) processEvent(event *Event) {

//mongo parts

if event.Mask.HasBit(MONGOKO) {
if eventWatcher.eventsMask.HasBit(MONGOKO) {
var pushEvent = bson.M{"type": 1, "code": "MONGOKO", "data": event.Datas}
if event.Mask.HasBit(MONGKO) {
if eventWatcher.eventsMask.HasBit(MONGKO) {
var pushEvent = bson.M{"type": 1, "code": "MONGKO", "data": event.Datas}
eventWatcher.publishEvent(pushEvent)
eventWatcher.eventsMask.Clear(MONGOKO)
eventWatcher.eventsMask.Set(MONGOOK)
eventWatcher.eventsMask.Clear(MONGKO)
eventWatcher.eventsMask.Set(MONGOK)
}

}

if event.Mask.HasBit(MONGOOK) {
if eventWatcher.eventsMask.HasBit(MONGOOK) {
var pushEvent = bson.M{"type": 1, "code": "MONGOOK", "data": event.Datas}
if event.Mask.HasBit(MONGOK) {
if eventWatcher.eventsMask.HasBit(MONGOK) {
var pushEvent = bson.M{"type": 1, "code": "MONGOK", "data": event.Datas}
eventWatcher.publishEvent(pushEvent)
eventWatcher.eventsMask.Clear(MONGOOK)
eventWatcher.eventsMask.Set(MONGOKO)
eventWatcher.eventsMask.Clear(MONGOK)
eventWatcher.eventsMask.Set(MONGKO)
}

}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ func importJob() {
session, err := mgo.Dial(config.MongoHost)
if err != nil {
log.Debugf("Can't connect to the mongo database error : %s.", err)
sendMongoEventNotification(MONGOKO)
sendMongoEventNotification(MONGKO)
return
}
session.SetMode(mgo.Monotonic, true)
defer session.Close()
sendMongoEventNotification(MONGOOK)
sendMongoEventNotification(MONGOK)
log.Debug("Connected to the mongo database with success.")
//
cdrs, err := getMysqlCdr(db)
Expand Down

0 comments on commit debbb95

Please sign in to comment.