-
I need to listen and unlisten while also waiting for notifications. What's the best way to do this -- two goroutines, the first to receive (via WaitForNotification) and dispatch notifications, and the second to maintain subscription lifecyles (via Exec "listen" and "unlisten")? I suspect thats not a good idea, but I don't know how else to do it. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Beta Was this translation helpful? Give feedback.
*pgx.Conn
is not concurrency safe, so you can't use two goroutines. You would need to cancel the context passed toWaitForNotification
, then execute yourlisten
orunlisten
, then recallWaitForNotification
.