I’m confused when I was reading the Kafka Code.The code is shown as follow.
def handleRequest[Req <: AsyncRequest](request: Req): Req#Response = {
handleRequests(Seq(request)).head
}
sealed trait AsyncRequest {
/**
* This type member allows us to define methods that take requests and return responses with the correct types.
* See ``ZooKeeperClient.handleRequests`` for example.
*/
type Response <: AsyncResponse
def path: String
def ctx: Option[Any]
}
case class CreateRequest(path: String, data: Array[Byte], acl: Seq[ACL], createMode: CreateMode,
ctx: Option[Any] = None) extends AsyncRequest {
type Response = CreateResponse
}
sealed abstract class AsyncResponse {
def resultCode: Code
def path: String
def ctx: Option[Any]
...
}
case class CreateResponse(resultCode: Code, path: String, ctx: Option[Any], name: String,
metadata: ResponseMetadata) extends AsyncResponse
My question is what’s the meaning of “Req#Response”?