For debugging purpose, it's useful to know the client ip from which a request comes.
This doesn't seem too hard. In Processor.read(), we can add socketChannel.socket.getRemoteSocketAddress() to RequestChannel.Request.
You want the ip in RequestOrReponse object for it to be useful when logging the different requests. This would be in RequestChannel.Request.RequestOrReponse. We currently only deserialize from the received buffer to create this object. It would require little more plumbing to have the ip available in these request objects.
I was thinking of just putting the ip in RequestChannel.Request.
Thanks for the patch, Sriram! Few very minor comments -
"from remote address" -> "from client"
I don't think we need to have a default for remoteAddress, no ?
1. changed the string
2. you need it because there are multiple test cases which create this object.
Looks good. Just 1 comment:
10. RichString.format() seems expensive. We probably should use string + in the following statement.
requestLogger.trace("Handling request: %s from remote address: %s".format(request.requestObj, request.remoteAddress))
Checked in v2 after addressing Jun's suggestion