7120a729bd
+ DB access is now right and uses copied sessions + DB session is now specifying the safe state and the mode + Fixed the issue with too early ICCC messages regarding to late cache + Add the MIME type for Dart + Fixed the issuse with wrong order of shutdown handlers - TODO: Testing of these changes
29 lines
977 B
Go
29 lines
977 B
Go
package NumGen
|
|
|
|
import "labix.org/v2/mgo"
|
|
import "github.com/SommerEngineering/Ocean/CustomerDB"
|
|
import "github.com/SommerEngineering/Ocean/Log"
|
|
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
|
|
|
func initDB() {
|
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Start init of number generator collection.`)
|
|
defer Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Done init of number generator collection.`)
|
|
|
|
// Get the database:
|
|
dbSession, db = CustomerDB.DB()
|
|
|
|
if db == nil {
|
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameDATABASE, `Was not able to get the customer database.`)
|
|
return
|
|
}
|
|
|
|
// Get my collection:
|
|
collectionNumGen = db.C(`NumGen`)
|
|
|
|
// Take care about the indexes:
|
|
indexName := mgo.Index{}
|
|
indexName.Key = []string{`Name`}
|
|
indexName.Unique = true
|
|
collectionNumGen.EnsureIndex(indexName)
|
|
}
|