Skip to content

Delete the 2018 protocol module - #7

Merged
m13m merged 1 commit into
masterfrom
phase-2-connection-rewire
Oct 29, 2026
Merged

m13m merged 1 commit into
masterfrom
phase-2-connection-rewire

Conversation

@m13m

@m13m m13m commented Oct 29, 2026

Copy link
Copy Markdown
Member

Reopened against master. #6 merged into phase-2-handshake after that branch had already landed via #5, so this commit never reached master. Same single commit, nothing else changed.

Mysqlex.Client now runs the connection phase, which left the 2018 handshake parsing in Mysqlex.Protocol as dead code.

deleted:  lib/mysqlex/protocol.ex       the 2018 handshake + the stubs
created:  lib/mysqlex/connection.ex     a DBConnection wrapper over Client

handshake/1, parse_header/1, parse_payload_body/2 and recv_msg/2 — what this project consisted of for eight years — are gone. Their last contribution was being the code run against real captured bytes to demonstrate the MatchError on MySQL 8.4.4.

Three things settled

Decision 12 is closed. Mysqlex.Protocol meant both the DBConnection implementation and the namespace holding the codecs. Now Mysqlex.Connection is the behaviour and Mysqlex.Protocol.* is unambiguously the parsers. Renamed while it was still small, as the decision said to.

The wrapper is thin on purpose. connect/1 delegates and the state is a %Mysqlex.Client{}. Nothing below connection.ex knows DBConnection exists, which keeps decision 15's swap cheap rather than theoretical.

Mysqlex.Error is an exception now, because DBConnection specifies its callbacks as returning Exception.t() — listed as inevitable when the struct was created, now forced by the contract. Failures that are not server errors, like a dead socket or an auth method the driver cannot speak, are wrapped rather than returned raw, since the contract wants an exception either way.

Coverage

An integration test connects through DBConnection.start_link/2, so the wrapper is exercised rather than assumed. 50 tests with --include integration.

The command phase callbacks still return DBConnection.ConnectionError. COM_QUERY is next.

Mysqlex.Client now does the connection phase properly, which left the
2018 handshake parsing in Mysqlex.Protocol as dead code. Deleted, and
the module renamed to Mysqlex.Connection — settling decision 12, since
"protocol" meant both the DBConnection implementation and the namespace
holding the codecs.

Its state is a %Mysqlex.Client{} and connect/1 delegates, so the
behaviour is a wrapper rather than a participant. That is what keeps
decision 15's option open: nothing below this file knows DBConnection
exists.

Mysqlex.Error becomes an exception, since DBConnection specifies its
callbacks as returning Exception.t(). Failures that are not server
errors — a dead socket, an auth method we cannot speak — are wrapped in
one rather than returned raw, because the contract asks for an
exception either way.

An integration test connects through DBConnection itself, so the
wrapper is covered rather than assumed.
@m13m
m13m merged commit fc538eb into master Oct 29, 2026
6 checks passed
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.

1 participant