go func() {
if err := w.listenMessage(listenerCtx); err == context.Canceled {
log.Println("[psqlwatcher] watcher closed")
} else if err != nil {
// after error we end up here and won't be able to receive any updates
log.Printf("[psqlwatcher] failed to listen message: %v\n", err)
}
}()
But also if we restore listening after reconnect, we must trigger update policy implicitly, because some notifications may skipped at this moment. Postgres listen / notify has no guarantee about receiving notification if no body listen it.
Hi!
For now watcher cannot restore listening if Postgres connection is lost. https://github.com/IguteChung/casbin-psql-watcher/blob/main/watcher.go#L79
But also if we restore listening after reconnect, we must trigger update policy implicitly, because some notifications may skipped at this moment. Postgres listen / notify has no guarantee about receiving notification if no body listen it.