-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathinfo.go
49 lines (40 loc) · 1.09 KB
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package fxworker
import (
"time"
"github.com/ankorstore/yokai/worker"
)
// FxWorkerModuleInfo is a module info collector for fxcore.
type FxWorkerModuleInfo struct {
pool *worker.WorkerPool
}
// NewFxWorkerModuleInfo returns a new [FxWorkerModuleInfo].
func NewFxWorkerModuleInfo(pool *worker.WorkerPool) *FxWorkerModuleInfo {
return &FxWorkerModuleInfo{
pool: pool,
}
}
// Name return the name of the module info.
func (i *FxWorkerModuleInfo) Name() string {
return ModuleName
}
// Data return the data of the module info.
func (i *FxWorkerModuleInfo) Data() map[string]interface{} {
data := map[string]interface{}{}
for name, execution := range i.pool.Executions() {
var events []map[string]string
for _, event := range execution.Events() {
events = append(events, map[string]string{
"execution": event.ExecutionId(),
"message": event.Message(),
"time": event.Timestamp().Format(time.DateTime),
})
}
data[name] = map[string]interface{}{
"status": execution.Status().String(),
"events": events,
}
}
return map[string]interface{}{
"workers": data,
}
}