-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finatra: StackTransformer for Finatra
Problem / Solution There isn't a general mechanism to modify the filters applied to routes when they get built. Finagle uses StackTransformer to modify server stacks, Finatra can use it too if we replace its filter building mechanisms with equivalent stack building ones. JIRA Issues: CSL-7673 Differential Revision: https://phabricator.twitter.biz/D277493
- Loading branch information
1 parent
ce05c72
commit a96312d
Showing
6 changed files
with
72 additions
and
29 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
inject/inject-modules/src/main/scala/com/twitter/inject/modules/StackTransformerModule.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.twitter.inject.modules | ||
|
||
import com.twitter.finagle.{ServiceFactory, Stack, StackTransformer} | ||
import com.twitter.finagle.util.LoadService | ||
import com.twitter.inject.TwitterModule | ||
|
||
/** | ||
* Provides a [[com.twitter.finagle.StackTransformer]] to the dependency | ||
* injection context. | ||
*/ | ||
object StackTransformerModule extends TwitterModule { | ||
override protected def configure(): Unit = | ||
bindSingleton[StackTransformer].toInstance(loadStackTransformer) | ||
|
||
private[this] def loadStackTransformer: StackTransformer = | ||
new StackTransformer { | ||
private[this] val transformers = LoadService[StackTransformer] | ||
|
||
val name: String = StackTransformerModule.this.getClass.getName | ||
|
||
def apply[Req, Rep](stackSvcFac: Stack[ServiceFactory[Req, Rep]]): Stack[ServiceFactory[Req, Rep]] = | ||
transformers.foldLeft(stackSvcFac)((stack, transform) => transform(stack)) | ||
} | ||
} |
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
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
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
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