diff --git a/ConfigurationDB/Init.go b/ConfigurationDB/Init.go index 76cae61..6fb2668 100644 --- a/ConfigurationDB/Init.go +++ b/ConfigurationDB/Init.go @@ -37,7 +37,6 @@ func init() { // Take care about the index: collection.EnsureIndexKey(`Name`) - collection.EnsureIndexKey(`Value`) checkConfiguration() Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameDATABASE, `The configuration database is now ready.`) diff --git a/ConfigurationDB/Write.go b/ConfigurationDB/Write.go new file mode 100644 index 0000000..50f7422 --- /dev/null +++ b/ConfigurationDB/Write.go @@ -0,0 +1,25 @@ +package ConfigurationDB + +import "github.com/SommerEngineering/Ocean/Log" +import LM "github.com/SommerEngineering/Ocean/Log/Meta" +import "labix.org/v2/mgo/bson" + +/* +This function writes the configuration value. +*/ +func Write(name, value string) { + if name == `` { + Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityUnknown, LM.ImpactUnknown, LM.MessageNameDATABASE, `Was not able to write a configuration to the database.`, `The given name was nil!`) + return + } + + result := ConfigurationDBEntry{} + if errFind := collection.Find(bson.D{{"Name", name}}).One(&result); errFind != nil { + Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityUnknown, LM.ImpactUnknown, LM.MessageNameDATABASE, `Was not able to write a configuration to the database.`, `Error while find.`, errFind.Error()) + return + } + + result.Value = value + collection.Update(bson.D{{"Name", name}}, result) + return +} diff --git a/Log/Meta/MessageNames.go b/Log/Meta/MessageNames.go index ebf9401..1a64940 100644 --- a/Log/Meta/MessageNames.go +++ b/Log/Meta/MessageNames.go @@ -31,4 +31,8 @@ const ( MessageNamePRODUCER = `Producer` MessageNameCONSUMER = `Consumer` MessageNamePASSWORD = `Password` + MessageNamePARSE = `Parse` + MessageNameUSER = `User` + MessageNameREQUEST = `Request` + MessageNameRESPONSE = `Response` ) diff --git a/Shutdown/Init.go b/Shutdown/Init.go index ca3a82b..312f589 100644 --- a/Shutdown/Init.go +++ b/Shutdown/Init.go @@ -4,8 +4,11 @@ import "container/list" import "os/signal" import "os" -func InitShutdown() { +func init() { shutdownHandlers = list.New() +} + +func InitShutdown() { // Apply the shutdown handler: signal.Notify(shutdownSignal, os.Interrupt, os.Kill)