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

emit connection object on new connection #61

Merged
merged 1 commit into from Jul 11, 2019

Conversation

mafischer
Copy link
Contributor

@mafischer mafischer commented Jun 17, 2019

coming from mysql, I really miss having the ability to set up session settings when a new connection becomes available.

https://github.com/mysqljs/mysql#connection

pool.on('new-conn', function (conn) {
  conn.query('SET SESSION auto_increment_increment=1')
});

The only caveat is that the event name is new-conn whereas in mysql it was connection. As long it's documented it's not a big deal.

lib/pool-base.js Outdated
@@ -379,7 +379,7 @@ function PoolBase(options, processTask, createConnectionPool, pingPromise) {
connectionInCreation = false;
idleConnections.push(conn);
pool.emit('idle-conn');
pool.emit('new-conn');
pool.emit('new-conn', conn);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small improvement: better to use async event emiting then:
process.nextTick(() => pool.emit('new-conn', conn));
(and it will solve error in tests suite btw)

@rusher
Copy link
Collaborator

rusher commented Jun 17, 2019

Nice addition btw. I'll merge after review correction is done.

@mafischer
Copy link
Contributor Author

@rusher I also updated the documentation to reflect the changes, I hope that is ok.

@rusher
Copy link
Collaborator

rusher commented Jun 18, 2019

Nice, I'll merge that in develop branch.

Regarding the mysql documentation,
I think next version will be 2.1.0, even if those events were not documented, to change this event new-conn to connection, and add acquire, enqueue and release at the same time.

@mafischer
Copy link
Contributor Author

@rusher can you provide an approximate timeline for the release of 2.1.0?

@rusher
Copy link
Collaborator

rusher commented Jul 9, 2019

@mafischer soon. probably Thursday or Friday.

@rusher rusher merged commit cc80a55 into mariadb-corporation:master Jul 11, 2019
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

Successfully merging this pull request may close these issues.

None yet

2 participants