Closed Sannis closed 12 years ago
@aleafs, @iseeyou1987, @avz - are this changes good for you?
Hi @Sannis , really sorry for coming late, and thanks for your issue. Only one thing is that I have not figured out how these apis are helpful for slow queries. We use connections pool and querySend to communicate with mysql. When connections are run out, we push a new query into a queque before trigger "review_quequed_query" in nextTick.
Currently my library use libeio threads for queries to MySQL server. Default thread pool size is 4, as @iseeyou1987 right mentioned. So if you start 8 queries, they block all threads and you can't run any libeio operations, such as other queries or file I/O. With mysql_send_query
you solves this problem, but you can't run them in parallel. So need to use connection pool plus custom queue for sequalize queries in each copnnection. I think you are know this, so I've describe this for anyone who need this explanation.
It is quite good, that node community wrote modules for common resource polls and queues, but I think that such queue need to be in node-mysql-libmysqlclient
itself, besause in other case some users may be confused with issues like #123. So MysqlConnectionQueued
should implement such queues for query
and querySend
to avoid thread pool cluttering. I think it will be also helpful for you. Also, it should support things like this:
var conn = mysql.createConnection();
conn.connect(...); // async call without callback
conn.query("INSERT ..."); // async query, will be executed after connection
This issue includes API proposal for the high-level API.
Define:
mysql = require('mysql-libmysqlclient')
.mysql.createConnectionSync()
should returnMysqlConnection
-compatible object. Guarantied by tests.mysql.binding
property should return exactly bindings without any changes. Done in 83f69052bea2619e78017874fe847ce55a766649.mysql.MysqlConnectionQueued
should be inherited frommysql.binding.MysqlConnection
and use queue forconnect
,query
andquerySend
methods. Done in #117.mysql.MysqlConnectionHighlevel
should be a high-level API, includes only async functions frommysql.MysqlConnectionQueued
. It should have a switch, what method is used for querying:query
orquerySend
. Started in 28527d612cff08c8e616ddd0ef7d9ace6fe18a33.