Created
October 23, 2014 20:55
-
-
Save dschobel/a773c6c1bddc3e2d2b1d to your computer and use it in GitHub Desktop.
finagle filter in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.twitter.finagle.Service; | |
import com.twitter.finagle.SimpleFilter; | |
import com.twitter.util.Future; | |
public class MyThriftRequest { public int Attribute = 123; } | |
public class LoggingFilter extends SimpleFilter<MyThriftRequest, MyThriftResponse> { | |
private static final Logger LOG = Logger.getLogger(LoggingFilter.class); | |
private void logRequest(MyThriftRequest request) { | |
String logMessage = "saw request with Attribute " + request.Attribute; | |
LOG.info(logMessage); | |
} | |
@Override | |
public Future<MyThriftResponse> apply(MyThriftRequest request, Service<MyThriftRequest, MyThriftResponse> service) { | |
logRequest(request); | |
return service.apply(request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment