Skip to content

Commit

Permalink
finagle-core: introduce new type-safe ReqRep variant
Browse files Browse the repository at this point in the history
Problem

`ReqRep` is not type-safe. For most scenarios,
`ReqRep` can be type-safe.

Solution

Introduce a generic, type-safe `ReqRepT` and
modify the existing `ReqRep` to be compatible.
This means that `ReqRepT` is itself a `ReqRep`
and can be used as a drop-in replacement where
type-safety is allowed.

JIRA Issues: CSL-10019

Differential Revision: https://phabricator.twitter.biz/D520027
  • Loading branch information
enbnt authored and jenkins committed Jul 24, 2020
1 parent 8084472 commit c5f95e4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public Future<Response> apply(noExceptionCall_args args) {
private void setReqRepContext(Object req, com.twitter.util.Try<Object> rep) {
scala.Option<ServerToReqRep> serdeCtx = com.twitter.finagle.context.Contexts.local().get(ServerToReqRep.Key());
if (serdeCtx.nonEmpty()) {
serdeCtx.get().setReqRep(new com.twitter.finagle.service.ReqRep(req, rep));
serdeCtx.get().setReqRep(com.twitter.finagle.service.ReqRep.apply(req, rep));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public Future<Integer> apply(moreCoolThings_args args) {
private void setReqRepContext(Object req, com.twitter.util.Try<Object> rep) {
scala.Option<ServerToReqRep> serdeCtx = com.twitter.finagle.context.Contexts.local().get(ServerToReqRep.Key());
if (serdeCtx.nonEmpty()) {
serdeCtx.get().setReqRep(new com.twitter.finagle.service.ReqRep(req, rep));
serdeCtx.get().setReqRep(com.twitter.finagle.service.ReqRep.apply(req, rep));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ public class {{name}} {
private void setReqRepContext(Object req, com.twitter.util.Try<Object> rep) {
scala.Option<ServerToReqRep> serdeCtx = com.twitter.finagle.context.Contexts.local().get(ServerToReqRep.Key());
if (serdeCtx.nonEmpty()) {
serdeCtx.get().setReqRep(new com.twitter.finagle.service.ReqRep(req, rep));
serdeCtx.get().setReqRep(com.twitter.finagle.service.ReqRep.apply(req, rep));
}
}

Expand Down

0 comments on commit c5f95e4

Please sign in to comment.