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

PostgreSQL support #799

Open
Vad1mo opened this issue Oct 4, 2023 · 9 comments
Open

PostgreSQL support #799

Vad1mo opened this issue Oct 4, 2023 · 9 comments
Labels
broker support Propose a new broker support

Comments

@Vad1mo
Copy link

Vad1mo commented Oct 4, 2023

Is your feature request related to a problem? Please describe.

I am aware that PostgreSQL is now a Message Queue per se; however, it can be utilized as such. Many developers realize that it suffices for the majority of tasks, and it comes with zero added costs if a PostgreSQL db is present.

Describe the solution you'd like
Clearly and concisely describe the desired outcome or solution.

Feature code example
Nothing in particular

Describe alternatives you've considered
You can do exactly this with MySQL and SQL server too because they both support SKIP LOCKED.

Additional context

@Vad1mo Vad1mo added the enhancement New feature or request label Oct 4, 2023
@Lancetnik Lancetnik moved this to Backlog in FastStream Oct 4, 2023
@Lancetnik Lancetnik removed their assignment Oct 16, 2023
@acaloiaro
Copy link

acaloiaro commented Nov 1, 2023

@Vad1mo 👋 I came across this by chance and see you've referenced my write up on the topic of PG as a queue.

If you find Go easy enough to read, you might benefit from reading the neoq source (https://github.com/acaloiaro/neoq) as a reference implementation for the ideas lain out in my post. The whole PG implementation is contained within: https://github.com/acaloiaro/neoq/blob/main/backends/postgres/postgres_backend.go

Cheers!

@Vad1mo
Copy link
Author

Vad1mo commented Nov 1, 2023

@Vad1mo 👋 I came across this by chance and see you've referenced my write up on the topic of PG as a queue.

If you find Go easy enough to read, you might benefit from reading the neoq source (https://github.com/acaloiaro/neoq) as a reference implementation for the ideas lain out in my post. The whole PG implementation is contained within: https://github.com/acaloiaro/neoq/blob/main/backends/postgres/postgres_backend.go

Cheers!

Found it already 👀 acaloiaro/neoq#70 🤣

@Lancetnik Lancetnik added broker support Propose a new broker support and removed enhancement New feature or request labels Nov 19, 2023
@Lancetnik Lancetnik changed the title Feature: PostgreSQL as a Queue PostgreSQL support Nov 24, 2023
@Lancetnik
Copy link
Member

I don't like an idea to poll DB for updates
I am thinking about Listen/Notify PG feature or even CDC (replication journal) consuming

@Vad1mo
Copy link
Author

Vad1mo commented Nov 24, 2023

Yes, I was referring to listen/notify. No mention about polling.
Regarding CDC, here I am not sure how or if it is low level, hence if it can be easily setup within the offerings of cloud providers.

@Lancetnik
Copy link
Member

CDC available from any pg driver: asyncpg/psycopg/etc
It is just a part of protocol
So, it can be a useful feature as I can image

@mixartemev
Copy link

Hey guys! I really need it asap. R u planning to implement it in nearest future or should I search other tools for manage pg listen/notify queues?

@Lancetnik
Copy link
Member

Hey guys! I really need it asap. R u planning to implement it in nearest future or should I search other tools for manage pg listen/notify queues?

Sorry, I don't think, that we can add Postgres support this year. Probably, we can do it in the first half of 2025, but can't strongly promise 😢

@mcproger
Copy link

Hey @Lancetnik

I've built a simple PoC with the listen/notify approach (took a couple of hours, so not the best code quality) that shows the general idea – link

If you are OK with this way, I would like to try to implement this feature. I'm still tinkering with the source code so if you can point places to start with it would be very helpful (if no - not a problem, just will spend a little bit more time reading the code).

Thanks

@Lancetnik
Copy link
Member

@mcproger Hi! Thank you a lot for your interest! I am appriciate any help with Postgres support and will be glad to work on it with you. But, can you wait for 0.6 release? I plan to unlock new brokers support after it and release SQS as a 0.7 one.

Anyway, you can start to work on Postgres already basing on 0.6 branch - it is almost ready to release.

To implement a new broker you should follow these steps

  1. Implement broker connect, _connect and start methods
    At this step, FastStream(PostgresBroker()) should be runnable already
  2. Then, you should create a subscriber class and register it in the broker
    So, @broker.subscriber(...) should be able to consume a messages already
  3. Next step you should impl a Producer class, and broker.publish - it should work already and subscriber can consume your messages already
  4. Then you can impl a publish class to use it as a @broker.publisher(...) decorator
  5. Finally, you should add AsyncAPI specification support, TestClient with MemoryProducer and add FastAPI support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broker support Propose a new broker support
Projects
Status: Backlog
Development

No branches or pull requests

5 participants