Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
apps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Go
apps
Commits
8244b42d
Commit
8244b42d
authored
3 weeks ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Added devices counter
parent
ef078cdd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/devices_counter.go
+46
-0
46 additions, 0 deletions
misc/devices_counter.go
with
46 additions
and
0 deletions
misc/devices_counter.go
0 → 100644
+
46
−
0
View file @
8244b42d
package
main
import
(
"log/slog"
"time"
"github.com/davecgh/go-spew/spew"
"gitlab.imt-atlantique.fr/xaal/code/go/core/uuid"
"gitlab.imt-atlantique.fr/xaal/code/go/core/xaal"
)
type
Counter
struct
{
Type
string
Until
time
.
Time
}
var
(
devices
map
[
uuid
.
UUID
]
Counter
)
func
handleMessage
(
msg
*
xaal
.
Message
)
{
if
msg
.
IsAlive
()
{
timeout
:=
msg
.
Body
[
"timeout"
]
if
timeout
==
nil
{
return
}
slog
.
Debug
(
"Received alive message from"
,
"timeout"
,
timeout
)
devices
[
msg
.
Source
]
=
Counter
{
Type
:
msg
.
DevType
,
Until
:
time
.
Now
()}
// msg.Dump()
// fmt.Println()
}
}
func
init
()
{
xaal
.
SetupLogger
(
slog
.
LevelDebug
)
}
func
main
()
{
eng
:=
xaal
.
NewEngine
()
eng
.
DisableMessageFilter
()
devices
=
make
(
map
[
uuid
.
UUID
]
Counter
)
eng
.
Subscribe
(
handleMessage
)
eng
.
Run
()
spew
.
Dump
(
devices
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment