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

@@ -186,9 +186,11 @@ type ForeignKey struct {
}
// Init implements handler.Init
func (h *StatementHandler) Init(ctx context.Context, checks ...*handler.Check) error {
func (h *StatementHandler) Init(ctx context.Context, initialized chan<- bool, checks ...*handler.Check) error {
for _, check := range checks {
if check == nil || check.IsNoop() {
initialized <- true
close(initialized)
return nil
}
tx, err := h.client.BeginTx(ctx, nil)
@@ -211,6 +213,8 @@ func (h *StatementHandler) Init(ctx context.Context, checks ...*handler.Check) e
return err
}
}
initialized <- true
close(initialized)
return nil
}