From debbb95d628c64af749a361fe6a900d3656d3af9 Mon Sep 17 00:00:00 2001 From: vassilux Date: Tue, 14 Oct 2014 21:28:05 +0200 Subject: [PATCH] Change mongo state --- config.json | 3 +-- evwatcher.go | 28 ++++++++++++++-------------- main.go | 4 ++-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/config.json b/config.json index 036a043..831d287 100644 --- a/config.json +++ b/config.json @@ -13,8 +13,7 @@ "asteriskPassword": "lepanos", "testCallSchedule": 20, "notifications": [ - "f1com", - "smtp" + "f1com" ], "dialplanContext": [ { "name": "app-out", "direction": 1}, diff --git a/evwatcher.go b/evwatcher.go index 5a533f4..5b13418 100644 --- a/evwatcher.go +++ b/evwatcher.go @@ -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 @@ -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) @@ -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) } } diff --git a/main.go b/main.go index 70f90e9..98d7156 100644 --- a/main.go +++ b/main.go @@ -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)