Skip to content

Commit

Permalink
emit in goroutine
Browse files Browse the repository at this point in the history
Signed-off-by: Giovanni Liva <[email protected]>
  • Loading branch information
thisthat committed Aug 9, 2023
1 parent 80d1112 commit 2c9af46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lifecycle-operator/controllers/common/eventsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (e *EventMultiplexer) register(emitter IEvent) {
func (e *EventMultiplexer) Emit(phase apicommon.KeptnPhaseType, eventType string, reconcileObject client.Object, status string, message string, version string) {
for _, emitter := range e.emitters {
e.logger.Info(fmt.Sprintf("Emitting event using %T", emitter))
emitter.Emit(phase, eventType, reconcileObject, status, message, version)
go emitter.Emit(phase, eventType, reconcileObject, status, message, version)
}
}

Expand Down
4 changes: 3 additions & 1 deletion lifecycle-operator/controllers/common/eventsender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ func TestEventSender_Multiplexer_emit(t *testing.T) {
// fire a new event
msg := "my special message"
emitter.Emit(common.PhaseAppDeployment, "", nil, "", msg, "")
// assert we got one event each
// assert we got one event
// let's wait few seconds so the async emit takes place
<-time.After(3 * time.Second)
require.Equal(t, 2, len(emitter.emitters))
require.Equal(t, 1, len(em1.events))
require.Equal(t, 1, len(em2.events))
Expand Down

0 comments on commit 2c9af46

Please sign in to comment.