Skip to content

Commit

Permalink
[core] Send EnvId with TaskEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Feb 29, 2024
1 parent 03f1446 commit 1309105
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 57 deletions.
124 changes: 67 additions & 57 deletions common/protos/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/protos/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ message Ev_TaskEvent {
string hostname = 5;
string className = 6;
Traits traits = 7;
string envid = 8;
}

message Ev_CallEvent {
Expand Down
22 changes: 22 additions & 0 deletions core/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ import (
"github.com/AliceO2Group/Control/common"
"github.com/AliceO2Group/Control/common/controlmode"
"github.com/AliceO2Group/Control/common/event"
"github.com/AliceO2Group/Control/common/event/topic"
"github.com/AliceO2Group/Control/common/gera"
"github.com/AliceO2Group/Control/common/logger"
evpb "github.com/AliceO2Group/Control/common/protos"
"github.com/AliceO2Group/Control/common/utils"
"github.com/AliceO2Group/Control/common/utils/uid"
"github.com/AliceO2Group/Control/configuration/template"
Expand Down Expand Up @@ -497,9 +499,29 @@ func (t *Task) SendEvent(ev event.Event) {
t.mu.RLock()
defer t.mu.RUnlock()

busEvent := &evpb.Ev_TaskEvent{
Name: t.name,
Taskid: t.taskId,
State: t.state.String(),
Status: t.status.String(),
Hostname: t.hostname,
ClassName: t.className,
}

if t.parent == nil {
the.EventWriterWithTopic(topic.Task).WriteEvent(busEvent)
return
}

busEvent.Envid = t.parent.GetEnvironmentId().String()

taskEvent, ok := ev.(*event.TaskEvent)
if ok {
busEvent.State = taskEvent.State
busEvent.Status = taskEvent.Status
}
the.EventWriterWithTopic(topic.Task).WriteEvent(busEvent)

t.parent.SendEvent(ev)
}

Expand Down

0 comments on commit 1309105

Please sign in to comment.