mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
chore: ensure pubsub messages are delivered in order for in-memory variant (#6474)
PostgreSQL provides this guarantee, which led to some flakes in tests. See: https://github.com/coder/coder/actions/runs/4350034299/jobs/7600478096
This commit is contained in:
@@ -46,9 +46,16 @@ func (m *memoryPubsub) Publish(event string, message []byte) error {
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
for _, listener := range listeners {
|
||||
go listener(context.Background(), message)
|
||||
wg.Add(1)
|
||||
listener := listener
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
listener(context.Background(), message)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user