Skip to content

Commit

Permalink
Routing: public method to map (scope,prefix) to a cluster name (#403)
Browse files Browse the repository at this point in the history
* Update connector.go

* Update CHANGELOG.md

* Create resolver.go

* Update resolver.go
  • Loading branch information
phliar authored Oct 4, 2019
1 parent af7f3bb commit b2d0d65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v3.4.9 (unreleased)
- clarifying message on success of scope drop, to wait before re-creating
- modify the test cases using space as the delimiter between tags
- expose a method Resolve(scope,prefix) -> cluster

## v3.4.8 (2019-07-26)
- Add transport parameter to yarpc connector and cli
Expand Down
7 changes: 6 additions & 1 deletion connectors/routing/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ func (rc *Connector) String() string {
return fmt.Sprintf("[Routing %s]", rc.config.String())
}

// Resolve returns the destination engine for the given scope and name-prefix.
func (rc *Connector) Resolve(scope, namePrefix string) string {
return rc.config.getEngineName(scope, namePrefix)
}

// get connector by scope and namePrefix
func (rc *Connector) getConnector(scope, namePrefix string) (dosa.Connector, error) {
connName := rc.config.getEngineName(scope, namePrefix)
connName := rc.Resolve(scope, namePrefix)
c, ok := rc.connectors[connName]
if !ok {
return nil, fmt.Errorf("can't find %q connector", connName)
Expand Down
7 changes: 7 additions & 0 deletions connectors/routing/resolver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package routing

// Resolver is an object that knows about the map from (scope,prefix) to cluster.
type Resolver interface {
// Resolve maps a (scope, prefix) to a cluster name.
Resolve(scope, namePrefix string) string
}

0 comments on commit b2d0d65

Please sign in to comment.