-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathhandleeval.go
More file actions
53 lines (46 loc) · 1.48 KB
/
handleeval.go
File metadata and controls
53 lines (46 loc) · 1.48 KB
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
50
51
52
53
// Copyright (c) 2026 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0
package diag
import (
"github.com/lf-edge/eve/pkg/pillar/pubsub"
"github.com/lf-edge/eve/pkg/pillar/types"
)
// initEvalSub initializes subscription to EvalStatus from evalmgr
func initEvalSub(ps *pubsub.PubSub, ctx *diagContext) {
agentName := "diag"
warningTime := warningTime
errorTime := errorTime
// Subscribe to evaluation status from evalmgr (if available)
subEvalStatus, err := ps.NewSubscription(pubsub.SubscriptionOptions{
AgentName: "evalmgr",
MyAgentName: agentName,
TopicImpl: types.EvalStatus{},
Activate: false,
Ctx: ctx,
CreateHandler: handleEvalStatusCreate,
ModifyHandler: handleEvalStatusModify,
WarningTime: warningTime,
ErrorTime: errorTime,
})
if err != nil {
log.Fatal(err)
}
ctx.subEvalStatus = subEvalStatus
subEvalStatus.Activate()
}
func handleEvalStatusCreate(ctxArg interface{}, key string,
statusArg interface{}) {
handleEvalStatusImpl(ctxArg, key, statusArg)
}
func handleEvalStatusModify(ctxArg interface{}, key string,
statusArg interface{}, oldStatusArg interface{}) {
handleEvalStatusImpl(ctxArg, key, statusArg)
}
func handleEvalStatusImpl(ctxArg interface{}, key string,
statusArg interface{}) {
ctx := ctxArg.(*diagContext)
ctx.evalStatus = statusArg.(types.EvalStatus)
log.Functionf("handleEvalStatusImpl: key %s, IsEvaluationPlatform %t",
key, ctx.evalStatus.IsEvaluationPlatform)
triggerPrintOutput(ctx, "EvalStatus")
}