Bug fixes and improvements
- Bugfix: The configuration collection can not have a key for the values. - Bugfix: It was possible, that the shutdown handler list was init to late. + ConfigDB: It is now possible to write and therefore to change a configuration value. + Added a few more message names for the logger.
This commit is contained in:
parent
a007db1b79
commit
b50066ef5d
@ -37,7 +37,6 @@ func init() {
|
|||||||
|
|
||||||
// Take care about the index:
|
// Take care about the index:
|
||||||
collection.EnsureIndexKey(`Name`)
|
collection.EnsureIndexKey(`Name`)
|
||||||
collection.EnsureIndexKey(`Value`)
|
|
||||||
|
|
||||||
checkConfiguration()
|
checkConfiguration()
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameDATABASE, `The configuration database is now ready.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameDATABASE, `The configuration database is now ready.`)
|
||||||
|
25
ConfigurationDB/Write.go
Normal file
25
ConfigurationDB/Write.go
Normal file
@ -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
|
||||||
|
}
|
@ -31,4 +31,8 @@ const (
|
|||||||
MessageNamePRODUCER = `Producer`
|
MessageNamePRODUCER = `Producer`
|
||||||
MessageNameCONSUMER = `Consumer`
|
MessageNameCONSUMER = `Consumer`
|
||||||
MessageNamePASSWORD = `Password`
|
MessageNamePASSWORD = `Password`
|
||||||
|
MessageNamePARSE = `Parse`
|
||||||
|
MessageNameUSER = `User`
|
||||||
|
MessageNameREQUEST = `Request`
|
||||||
|
MessageNameRESPONSE = `Response`
|
||||||
)
|
)
|
||||||
|
@ -4,8 +4,11 @@ import "container/list"
|
|||||||
import "os/signal"
|
import "os/signal"
|
||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
func InitShutdown() {
|
func init() {
|
||||||
shutdownHandlers = list.New()
|
shutdownHandlers = list.New()
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitShutdown() {
|
||||||
|
|
||||||
// Apply the shutdown handler:
|
// Apply the shutdown handler:
|
||||||
signal.Notify(shutdownSignal, os.Interrupt, os.Kill)
|
signal.Notify(shutdownSignal, os.Interrupt, os.Kill)
|
||||||
|
Loading…
Reference in New Issue
Block a user