Giter Site home page Giter Site logo

Queue for async queries about ext-pq HOT 15 CLOSED

m6w6 avatar m6w6 commented on July 17, 2024
Queue for async queries

from ext-pq.

Comments (15)

m6w6 avatar m6w6 commented on July 17, 2024 1

Complex logic should be implemented in userland, because it's easier to implement, maintain and iterate over.

from ext-pq.

m6w6 avatar m6w6 commented on July 17, 2024

Yeah, while checking the test cases for issue #9 I noticed that behavior, too.

Let me think a few days about whether and how to implement that queue.

from ext-pq.

ParkFramework avatar ParkFramework commented on July 17, 2024

I'm think, new async API without hell callbacks, used coroutine - yield Generator.
Tomorrow writing prototype new async API.

from ext-pq.

m6w6 avatar m6w6 commented on July 17, 2024

without hell callbacks

❓ 😃

from ext-pq.

ParkFramework avatar ParkFramework commented on July 17, 2024

Yes, callbacks are many shortcomings, there are no exceptions, the code is divided into many parts, I do not like this node.js :)
http://callbackhell.com/

from ext-pq.

ParkFramework avatar ParkFramework commented on July 17, 2024

Let me think a few days about whether and how to implement that queue.

Perhaps a good solution is to use a pool free connections (sockets) in one instance pq\Connection?

pq\Statement - always used only single connection
pq\Transaction - always used only single connection

Connection::execAsync - used any free connections from pool.
This only way to make multi thread executing queries in PostgreSQL.

from ext-pq.

DaveRandom avatar DaveRandom commented on July 17, 2024

TL;DR I'm -1 on this being an issue with the extension, it's an issue with the consuming application.


I'm not sure that the extension is the right place to implement a queue like this - I'd much rather have some kind of LogicException when I try to execute a second command against a busy connection.

Queues and pools can be and frequently are implemented in userland, if the extension queues things as well that gets way harder to track, whereas an exception helps me find bugs in my queuing/pooling logic. There is no such thing as a universal queue or a universal pool that serves everyone's use case (someone might want a priority queue, someone might want some kind of advanced management of channel listeners, etc etc) and because of this I'd rather have nothing and keep the extension as a thin-ish wrapper over libpq with a nicer API, to serve as a primitive for building app logic around.

If the extension did provide this functionality, it should be in the form of decorator classes and not bolted on to the side of pq\Connection etc.

IMHO, YMMV, slippery when wet, <insert other disclaimers here>

from ext-pq.

ParkFramework avatar ParkFramework commented on July 17, 2024

Complex logic should be implemented in userland, because it's easier to implement, maintain and iterate over.

Well, I agree.

from ext-pq.

m6w6 avatar m6w6 commented on July 17, 2024

Currently a pq\Exception\RuntimeException is raised:

$ php -r '$c=new pq\Connection; $c->execAsync(""); $c->execAsync("");'

Fatal error: Uncaught pq\Exception\RuntimeException: Failed to execute query (another command is already in progress)

So marking it wontfix for now, please re-open if wanted.

from ext-pq.

docteurklein avatar docteurklein commented on July 17, 2024

I'm having a similar problem on a userland-impl of a connection pool: docteurklein/react-pq@4e61634

would you have an idea why ?

from ext-pq.

DaveRandom avatar DaveRandom commented on July 17, 2024

@docteurklein come and talk to me in Room 11, github issues is not a great place for such a conversation

from ext-pq.

m6w6 avatar m6w6 commented on July 17, 2024

So, was the problem resolved for @docteurklein?

from ext-pq.

DaveRandom avatar DaveRandom commented on July 17, 2024

Not as yet. no further discussion has taken place.

amphp/postgres has a working Pool implementation though, so I remain confident that this is a problem best solved in userland, at least in the context of async - in general there are too many external factors that need to be accounted for when dealing with connection management to create a useful API in the extension.

That said, it's possible that a synchronous Pool might be a useful thing, i.e. some kind of API that is conceptually similar to curl_multi_*(), whereby the top-level API is blocking but userland can pass in multiple "actions" to execute concurrently. I don't personally have a use-case, but I can imagine that they might exist.

from ext-pq.

docteurklein avatar docteurklein commented on July 17, 2024

oh sorry, I didn't see the notice in time :| I might not be fully available so an async form of messaging would work for me (even if harder to communicate). Thanks for the links BTW!

from ext-pq.

docteurklein avatar docteurklein commented on July 17, 2024

wow, crazy amount of work on amp/psql! nice job!

from ext-pq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.