-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
mysql: Add ConnectionReady callback to Handler interface #9496
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,10 @@ type Handler interface { | |
// In particular, ServerStatusAutocommit might be set. | ||
NewConnection(c *Conn) | ||
|
||
// ConnectionReady is called after the connection handshake, but | ||
// before we begin to process commands. | ||
ConnectionReady(c *Conn) | ||
|
||
// ConnectionClosed is called when a connection is closed. | ||
ConnectionClosed(c *Conn) | ||
|
||
|
@@ -470,6 +474,10 @@ func (l *Listener) handle(conn net.Conn, connectionID uint32, acceptTime time.Ti | |
log.Warningf("Slow connection from %s: %v", c, connectTime) | ||
} | ||
|
||
// Tell our handler that we're finished handshake and are ready to | ||
// process commands. | ||
l.handler.ConnectionReady(c) | ||
Comment on lines
+477
to
+479
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm open to where we think it's best to determine |
||
|
||
for { | ||
kontinue := c.handleNextCommand(l.handler) | ||
if !kontinue { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just filling in all of the other internal implementations of the
Handler
interface.When doing this, I was thinking it might be nice to introduce a stub
UnimplementedHandler
struct that all implementation can embed that provides default no-op handlers. Similar to how gRPC gives you the stub to satisfy the interface. That way an implementation isn't require to implement every callback if they're not needed.I'd be happy to follow up with an
UnimplementedHandler
struct if you also think this is valuable. It'd help wiht the boilerplate in the tests and all that get touched in this PR.