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

Support LISTEN/NOTIFY callback handlers #117

Open
oliverlambson opened this issue Jan 6, 2025 · 6 comments
Open

Support LISTEN/NOTIFY callback handlers #117

oliverlambson opened this issue Jan 6, 2025 · 6 comments

Comments

@oliverlambson
Copy link

oliverlambson commented Jan 6, 2025

I'd like to be able to add a callback handler similar to asyncpg's connection.add_listener(...)

I'm agnostic on the API, if there is a more idiomatic PSQLPy abstraction or interface that's cool—I just think it would be great to have the LISTEN/NOTIFY functionality exposed

@chandr-andr
Copy link
Member

Thanks for the feature request, we'll implement it.

@chandr-andr
Copy link
Member

@oliverlambson Hello!

If it's possible could you please describe how you usually use this functionality?

@oliverlambson
Copy link
Author

I use it to send notifications like events that a listener can then react to.

Being able to do that means I can implement an asynchronous message queue. I've implemented it from scratch in https://www.github.com/oliverlambson/pgmq (there are explanations there if it's helpful), and as a taskiq plugin https://www.github.com/karoo-ca/taskiq-pg

@chandr-andr
Copy link
Member

Okay, thank you very much

I've started implementing it but it'll be different in API from asyncpg.

@oliverlambson
Copy link
Author

Exciting!

@chandr-andr
Copy link
Member

@oliverlambson Hello!

I've made a new release 0.9.0 with support for LISTEN functionality. It's the first variant of API, so if you have any ideas on how to make it better, please let me know.
You can read new documentation about it here - https://psqlpy-python.github.io/components/listener.html

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