All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.finagle.mysql.transport.MysqlTransport.scala Maven / Gradle / Ivy

There is a newer version: 24.2.0
Show newest version
package com.twitter.finagle.mysql.transport

import com.twitter.finagle.mysql.QuitRequest
import com.twitter.finagle.transport.{Transport, TransportProxy}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.util.{Future, Time}

/**
 * A `MysqlTransport` is a representation of a stream of MySQL packets that
 * may be read from and written to asynchronously. It is also capable of
 * sending a proper `COM_QUIT` on close.
 */
private[mysql] final class MysqlTransport(_self: Transport[Packet, Packet])
    extends TransportProxy(_self) {

  def read(): Future[Packet] = _self.read()

  def write(input: Packet): Future[Unit] = _self.write(input)

  override def close(deadline: Time): Future[Unit] =
    write(QuitRequest.toPacket)
      .by(DefaultTimer, deadline)
      .ensure(_self.close(deadline))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy