fix: wait for projection initialization to be done (#4473)

* fix: wait for projection initialization to be done

* close channel

Co-authored-by: Silvan <silvan.reusser@gmail.com>
This commit is contained in:
Livio Spring
2022-10-03 16:09:59 +02:00
committed by GitHub
parent df624f0de5
commit fcb36cd406
4 changed files with 16 additions and 5 deletions

View File

@@ -62,6 +62,7 @@ func NewProjectionHandler(
query SearchQuery,
lock Lock,
unlock Unlock,
initialized <-chan bool,
) *ProjectionHandler {
concurrentInstances := int(config.ConcurrentInstances)
if concurrentInstances < 1 {
@@ -82,9 +83,12 @@ func NewProjectionHandler(
concurrentInstances: concurrentInstances,
}
go h.subscribe(ctx)
go func() {
<-initialized
go h.subscribe(ctx)
go h.schedule(ctx)
go h.schedule(ctx)
}()
return h
}