Comments (15)
Complex logic should be implemented in userland, because it's easier to implement, maintain and iterate over.
from ext-pq.
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.
I'm think, new async API without hell callbacks, used coroutine - yield
Generator.
Tomorrow writing prototype new async API.
from ext-pq.
without hell callbacks
❓ 😃
from ext-pq.
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.
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.
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.
Complex logic should be implemented in userland, because it's easier to implement, maintain and iterate over.
Well, I agree.
from ext-pq.
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.
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.
@docteurklein come and talk to me in Room 11, github issues is not a great place for such a conversation
from ext-pq.
So, was the problem resolved for @docteurklein?
from ext-pq.
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.
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.
wow, crazy amount of work on amp/psql! nice job!
from ext-pq.
Related Issues (20)
- Bug POLLING_OK? HOT 5
- Batch mode and query pipelining for PostgreSQL 9.6 HOT 4
- Failed test with 7.1.0RC6 HOT 19
- Segmentation fault after pg_terminate_backend
- raphf - is thread not safe HOT 6
- with-pq=NO HOT 3
- PHP 7.1.11 core dump HOT 4
- TimeZone issue
- Failed to acquire cancel (invalid socket) HOT 1
- pq\Types is restricted to non-composite types
- Ayn HOT 1
- Any chance for a new release? HOT 3
- Incompatible with PHP 8 HOT 2
- Missing status HOT 1
- Stub does not provide types of @var in docblock for pq\Connection::$socket and pq\LOB::$stream HOT 1
- Test failure with libpq 9.2
- Windows builds HOT 2
- ext-pq depends on raphf, but raphf last release is 4 years ago HOT 1
- pq\DateTime::__toString return type HOT 2
- JSON decoding is broken HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ext-pq.