-
Notifications
You must be signed in to change notification settings - Fork 341
Refactor serialization code #93
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
Conversation
The top level class that the driver interacts with should implement Stream or NetworkStream This would allow for streams to be chained as Middleware. For example, if compression and SSL were enabled, stream call stack would look like: Write: Caller.Write -> MySqlStream.Write -> MySqlCompressedStream.Write -> SslStream.Write -> the wire |
I decided against that for the following reasons:
|
Another reason against it: In my testing,
This is probably what we'll need to do for SSL then. The Compression piece looks to be MSQL Specific - on second thought, we can't just pipe the whole payload through a GZip stream. Each MySql packet has to be compressed conditionally. |
It certainly does a lot less allocation; see Stephen Toub's writeup here: https://blogs.msdn.microsoft.com/pfxteam/2011/12/15/awaiting-socket-operations/
This was also part of the reason behind the separation into three separate interfaces: a |
8f9890b
to
7655c60
Compare
7655c60
to
bdb6be7
Compare
7c52a5e
to
a25b2e5
Compare
This breaks
PacketTransmitter
up into multiple independent components:IPayloadWriter
: writes a MySQL command and its data to an underlying transmission layerIPacketWriter
: serializes MySQL packets for transmission via a byte-oriented protocolIByteWriter
: writes a byte array to a destinationSocket
supportReader
versions of the three above interfaces, that invert their behaviourNot only does this provide separation of concerns, it makes the "protocol stack" pluggable and should allow compression #31 and SSL #88 to be implemented much more easily.
This is a work-in-progress; pushed for early feedback. TODO: