Add possibility to provide version (#46)
This commit is contained in:
1 parent
44b236e2ef
commit
20b93f42d4
17 files changed
+122
-4
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package ICCC
|
||||
|
||||
import (
|
||||
"github.com/SommerEngineering/Ocean/ICCC/SystemMessages"
|
||||
"github.com/SommerEngineering/Ocean/Log"
|
||||
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||
"github.com/SommerEngineering/Ocean/System/Version"
|
||||
"github.com/SommerEngineering/Ocean/Tools"
|
||||
)
|
||||
|
||||
// The receiver function for the ICCC version message.
|
||||
func ICCCGetVersionReceiver(data map[string][]string) (result map[string][]string) {
|
||||
|
||||
// Recover from errors:
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityUnknown, LM.ImpactUnknown, LM.MessageNamePARSE, "Was not able to execute the ICCC get version message.")
|
||||
result = make(map[string][]string, 0)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
// Converts the HTTP form data into an object:
|
||||
_, _, obj := Data2Message(SystemMessages.ICCCGetVersion{}, data)
|
||||
|
||||
// Was it possible to convert the data?
|
||||
if obj != nil {
|
||||
|
||||
// Prepare the answer:
|
||||
answer := SystemMessages.ICCCGetVersionAnswer{}
|
||||
answer.Kind = `Ocean`
|
||||
answer.Name = Tools.ThisHostname()
|
||||
answer.Version = Version.GetVersion()
|
||||
|
||||
// An answer is necessary:
|
||||
return Message2Data("", "", answer)
|
||||
} else {
|
||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `ICCC message: Was not able to convert the ping message.`)
|
||||
}
|
||||
|
||||
// In any other error case:
|
||||
result = make(map[string][]string, 0)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package SystemMessages
|
||||
|
||||
// Requests the version from a Ocean server
|
||||
type ICCCGetVersion struct {
|
||||
}
|
||||
|
||||
// Answer to the version request
|
||||
type ICCCGetVersionAnswer struct {
|
||||
Kind string // Ocean || Component
|
||||
Name string // Ocean: Hostname; Components: Name
|
||||
Version string // The current version
|
||||
}
|
||||
@@ -4,9 +4,12 @@ package SystemMessages
|
||||
type ICCCOceanStartUpMessage struct {
|
||||
PublicIPAddressPort string // The public web server's IP address and port
|
||||
AdminIPAddressPort string // The private admin server's IP address and port
|
||||
OceanVersion string // The current version of this server
|
||||
}
|
||||
|
||||
// Message type for a startup message for external components:
|
||||
type ICCCComponentStartUpMessage struct {
|
||||
IPAddressPort string // The component's ICCC IP address and port
|
||||
Name string // What is the name of this component?
|
||||
Version string // Which version is used?
|
||||
}
|
||||
@@ -14,6 +14,7 @@ const (
|
||||
ChannelSHUTDOWN string = `System::Shutdown` // A channel for system shutdown messages.
|
||||
ChannelSTARTUP string = `System::Startup` // A channel for system startup messages.
|
||||
ChannelICCC string = `System::ICCC` // A common ICCC channel.
|
||||
ChannelPING string = `System::Ping` // A channel for pings.
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in new issue
Block a user