Skip to content

Commit

Permalink
Merge pull request fagongzi#108 from domgoer/master
Browse files Browse the repository at this point in the history
fix: routing is still available when down
  • Loading branch information
zhangxu19830126 authored Nov 26, 2018
2 parents 9122004 + 2df0ac4 commit b52cb9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/proxy/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (r *dispatcher) selectServer(req *fasthttp.Request, dn *dispathNode) {

func (r *dispatcher) adjustByRouting(apiID uint64, req *fasthttp.Request, dn *dispathNode) {
for _, routing := range r.routings {
if routing.matches(apiID, req) {
if routing.isUp() && routing.matches(apiID, req) {
svr := r.selectServerFromCluster(req, routing.meta.ClusterID)

switch routing.meta.Strategy {
Expand Down
4 changes: 4 additions & 0 deletions pkg/proxy/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ func (a *routingRuntime) matches(apiID uint64, req *fasthttp.Request) bool {
return n < int(a.meta.TrafficRate)
}

func (a *routingRuntime) isUp() bool {
return a.meta.Status == metapb.Up
}

func conditionsMatches(cond *metapb.Condition, req *fasthttp.Request) bool {
attrValue := paramValue(&cond.Parameter, req)
if attrValue == "" {
Expand Down

0 comments on commit b52cb9a

Please sign in to comment.