Skip to content

Commit

Permalink
finagle-mysql: Add docs to OK
Browse files Browse the repository at this point in the history
Problem / Solution

`OK` is a commonly used part of the finagle-mysql API and it is
undocumented.

JIRA Issues: CSL-6010

Differential Revision: https://phabricator.twitter.biz/D175534
  • Loading branch information
kevinoliver authored and jenkins committed May 30, 2018
1 parent c555467 commit 8b1f2a9
Showing 1 changed file with 22 additions and 6 deletions.
Expand Up @@ -77,12 +77,10 @@ case class HandshakeInit(
status: Short
) extends Result

/**
* Represents the OK Packet received from the server. It is sent
* to indicate that a command has completed succesfully.
* [[http://dev.mysql.com/doc/internals/en/generic-response-packets.html#packet-OK_Packet]]
*/
object OK extends Decoder[OK] {
/**
* @see [[http://dev.mysql.com/doc/internals/en/generic-response-packets.html#packet-OK_Packet]]
*/
def decode(packet: Packet): OK = {
val br = MysqlBuf.reader(packet.body)
try {
Expand All @@ -92,12 +90,30 @@ object OK extends Decoder[OK] {
br.readVariableLong(),
br.readUnsignedShortLE(),
br.readUnsignedShortLE(),
new String(br.take(br.remaining))
{
val remaining = br.remaining
if (remaining == 0) ""
else new String(br.take(remaining))
}
)
} finally br.close()
}
}

/**
* Represents the OK Packet received from the server. It is sent
* to indicate that a command (e.g. [[PreparedStatement.modify]])
* has completed successfully.
*
* @param affectedRows how many records were changed by the command.
*
* @param insertId the first automatically generated value successfully
* inserted for an AUTO_INCREMENT column for an INSERT statement.
*
* @param serverStatus server status bit mask.
* @param warningCount how many warnings were generated.
* @param message the status message, which will be an empty String if none is present.
*/
case class OK(
affectedRows: Long,
insertId: Long,
Expand Down

0 comments on commit 8b1f2a9

Please sign in to comment.