Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASweb-backend-go
Commits
3d086fdf
Commit
3d086fdf
authored
Sep 30, 2020
by
Sonja Happ
Browse files
AMQP: adapt to message format of VILLAScontroller
parent
f05efc99
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
amqp/amqpclient.go
View file @
3d086fdf
...
...
@@ -123,7 +123,7 @@ func ConnectAMQP(uri string) error {
var
sToBeUpdated
database
.
InfrastructureComponent
db
:=
database
.
GetDB
()
ICUUID
:=
gjson
.
Get
(
content
,
"properties.uuid"
)
.
String
()
ICUUID
:=
gjson
.
Get
(
content
,
"
payload.
properties.uuid"
)
.
String
()
if
ICUUID
==
""
{
log
.
Println
(
"AMQP: Could not extract UUID of IC from content of received message, COMPONENT NOT UPDATED"
)
}
else
{
...
...
@@ -133,12 +133,16 @@ func ConnectAMQP(uri string) error {
continue
}
var
timeSec
=
gjson
.
Get
(
content
,
"time"
)
.
Float
()
var
stateUpdateAt
=
time
.
Unix
(
0
,
int64
(
timeSec
*
1000000000
))
.
UTC
()
err
=
db
.
Model
(
&
sToBeUpdated
)
.
Updates
(
map
[
string
]
interface
{}{
//"Host": gjson.Get(content, "host"),
//"Type": gjson.Get(content, "model"),
"Uptime"
:
gjson
.
Get
(
content
,
"
status
.uptime"
),
"State"
:
gjson
.
Get
(
content
,
"
status
.state"
),
"StateUpdateAt"
:
time
.
Now
()
.
Format
(
time
.
RFC1123
),
// TODO should use the "when" of the status update
"Uptime"
:
gjson
.
Get
(
content
,
"
payload
.uptime"
),
"State"
:
gjson
.
Get
(
content
,
"
payload
.state"
),
"StateUpdateAt"
:
stateUpdateAt
.
Format
(
time
.
RFC1123
),
//"RawProperties": gjson.Get(content, "properties"),
})
.
Error
if
err
!=
nil
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment