Skip to content

Instantly share code, notes, and snippets.

@dschobel
Created October 23, 2014 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dschobel/a773c6c1bddc3e2d2b1d to your computer and use it in GitHub Desktop.
Save dschobel/a773c6c1bddc3e2d2b1d to your computer and use it in GitHub Desktop.
finagle filter in java
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