mysql icon indicating copy to clipboard operation
mysql copied to clipboard

Add support for custom streams

Open dgb opened this issue 10 years ago • 10 comments

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.

dgb avatar May 29 '15 22:05 dgb

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

dougwilson avatar May 29 '15 22:05 dougwilson

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"

sidorares avatar May 30 '15 00:05 sidorares

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

dougwilson avatar May 30 '15 00:05 dougwilson

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!

dgb avatar May 30 '15 05:05 dgb

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.

dougwilson avatar May 30 '15 05:05 dougwilson

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 avatar Jun 01 '15 21:06 dgb

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 ;)).

dgb avatar Sep 25 '15 07:09 dgb

can show any example?

silent-tan avatar Dec 18 '17 05:12 silent-tan

🎂

dgb avatar May 29 '20 17:05 dgb

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

pktippa avatar Oct 17 '20 04:10 pktippa