Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[finagle-core] Remove Namer trait from Dtab
Problem -- We have multiple ways to bind a name via a Dtab: Dtab itself is a `Namer`, and `NameInterpreter` convert a Path to a bound name, taking the Dtab into account. Solution -- Make local dtab resolution a NameInterpreter. Result -- One mechanism for resolving a path to a bound name using the dtab. RB_ID=711681 TBR=true
- Loading branch information
Showing
14 changed files
with
176 additions
and
132 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
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
24 changes: 24 additions & 0 deletions
24
finagle-core/src/main/scala/com/twitter/finagle/naming/DefaultInterpreter.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.finagle.naming | ||
|
||
import com.twitter.finagle._ | ||
import com.twitter.util.Activity | ||
|
||
/** | ||
* Interpret names against the Dtab, using the default evaluation | ||
* strategy. Recursively look up and rewrite paths according to entries | ||
* matching the path prefix in the Dtab. If a path does not match any | ||
* Dtab entry prefix, the global Namer is invoked to resolve it. This is | ||
* how paths starting with `/$/` are bound. | ||
*/ | ||
object DefaultInterpreter extends NameInterpreter { | ||
|
||
override def bind(dtab: Dtab, path: Path): Activity[NameTree[Name.Bound]] = { | ||
def lookup(path: Path): Activity[NameTree[Name]] = | ||
dtab.lookup(path) match { | ||
case NameTree.Neg => Namer.global.bind(NameTree.Leaf(path)) | ||
case t => Activity.value(t) | ||
} | ||
|
||
Namer.bind(lookup, NameTree.Leaf(path)) | ||
} | ||
} |
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
Oops, something went wrong.