From f6c68fe8ca5f6186209b9fad0248e1694d508ec5 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Thu, 10 Nov 2022 20:27:34 -0500 Subject: [PATCH] add comment --- app.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.go b/app.go index 71ef6cb..74b277b 100644 --- a/app.go +++ b/app.go @@ -192,11 +192,14 @@ func (a *App) Start() { // entity listeners runOnStartup for eid, etls := range a.entityListeners { for _, etl := range etls { + // ensure each ETL only runs once, even if + // it listens to multiple entities if etl.runOnStartup && !etl.runOnStartupCompleted { entityState, err := a.state.Get(eid) if err != nil { log.Default().Println("Failed to get entity state \"", eid, "\" during startup, skipping RunOnStartup") } + etl.runOnStartupCompleted = true go etl.callback(a.service, a.state, EntityData{ TriggerEntityId: eid,