Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 Listener for 2 channel #1139

Open
septiyanmudhiya502 opened this issue Oct 6, 2023 · 1 comment
Open

1 Listener for 2 channel #1139

septiyanmudhiya502 opened this issue Oct 6, 2023 · 1 comment

Comments

@septiyanmudhiya502
Copy link

Is it possible to use 1 listener to listen to 2 different channel ? Currently I'm using 1 same listener instance in 2 different service and both of them listen to different channel, however notification from channel 1 is received in instance 2.

@johto
Copy link
Contributor

johto commented Oct 12, 2023

You can listen an arbitrary number of PostgreSQL listen channels on a single pq.Listener. But all notifications will come out of the same Go chan, i.e. pq.Listener.NotificationChannel(). You have to distribute them to the relevant goroutines (or what have you) yourself. (Or use something like my notifydispatcher; though I now see that it's a bit outdated.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants