Skip to content

Add support for custom streams #1110

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add support for custom streams #1110

wants to merge 3 commits into from

Conversation

dgb
Copy link

@dgb dgb commented May 29, 2015

Hello,

I needed to connect to a SOCKS proxy, as in #725, so I added a stream option similar to the mysql2 library. It only takes a factory function right now; I could add support for a plain stream, but that seems like a more unusual use case than typical.

I basically copied the socket connection test, because that seemed most appropriate. Let me know if you'd like me to DRY that up, or if you have feedback on anything else.

@dougwilson
Copy link
Member

@sidorares any initial comments? Is this API compatible with the existing API in mysql2?

@sidorares
Copy link
Member

Yes, API is compatible.
@dgb would be good to add test of pool and try two connections (initially stream option was only "stream" and when used with pool it tried to perform handshake on a already opened connection, that's why semantics changed to be "give me please new duplex stream which represent fresh connection to server"

@dougwilson
Copy link
Member

Looks like the test is failing on Node.js 0.6 if you can take a look into it.

@dougwilson dougwilson self-assigned this May 30, 2015
@dgb
Copy link
Author

dgb commented May 30, 2015

Yep, I saw that failure--I'll look into it. I'll see about writing a pool test too. I don't think it'll be an issue since I'm only using a function for this option (mysql2 takes either a stream or a function), but I haven't thought too deeply about the full connection lifecycle and could be overlooking something.

Anyways, thanks for the feedback and have a good weekend!

@dougwilson
Copy link
Member

Anyways, thanks for the feedback and have a good weekend!

You, too! In fact, I looked a bit, and I think the issue is because you are using net.connect instead of net.createConnection, which acts differently in Node.js 0.6; you can grep this module for the net.createConnection and just copy that into your test and I believe that should fix the issue.

var common = require('../../common');

function streamFactory() {
return Net.connect({port: common.fakeServerPort});
Copy link
Member

Choose a reason for hiding this comment

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

Use Net.createConnection instead of Net.connect for Node.js 0.6

@dgb dgb force-pushed the config-stream branch from 7d3cdf3 to e34934d Compare June 1, 2015 19:52
@dgb
Copy link
Author

dgb commented Jun 1, 2015

Heya,

I updated the test to use net.createConnection and it looks like it's passing on Node.js 0.6 now.

As for testing pools goes: It looks like pools are only tested at the unit level (which uses a mock connection), and all of the integration tests are at the connection level. Shall I go ahead and add a test/integration/pool directory, or is there a reason for this/is that getting a little out of the scope of this PR?

@dgb
Copy link
Author

dgb commented Sep 25, 2015

Any word on this pull request? I'll gladly add some tests if need be, but like I said, might be outside of the scope of this patch. FWIW I figured whomever was looking at this went on vacation or something and forgot, and I kind of forgot as our API has been humming along on my fork, uneventfully (well, at least WRT the database library ;)).

@dougwilson dougwilson force-pushed the master branch 4 times, most recently from 5847ec8 to be37e88 Compare May 8, 2016 05:09
@dougwilson dougwilson force-pushed the master branch 3 times, most recently from 65c4c0c to fa96a75 Compare June 8, 2016 02:00
@dougwilson dougwilson force-pushed the master branch 2 times, most recently from 638d79d to 88bade0 Compare June 29, 2017 18:13
@silent-tan
Copy link

can show any example?

@dgb
Copy link
Author

dgb commented May 29, 2020

🎂

@pktippa
Copy link

pktippa commented Oct 17, 2020

Is the TCP/ IP over SSH support is available now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants