Skip to content

Commit

Permalink
added comments about routing in predictChildren (#4267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuyi Xue authored Sep 5, 2022
1 parent 803f89e commit 472d5dc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions executor/predictor/predictor_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ var (
envEnableRoutingInjection = len(os.Getenv(ENV_ENABLE_ROUTING_INJECTION)) != 0
)

// Routing-related constants.
// Ref: https://github.com/SeldonIO/seldon-core/blob/master/doc/source/analytics/routers.md
const (
// Route to all children.
routeToAllChildren = -1
// Route to no children.
routeToNoChildren = -2
// Any other positive integer N means route to child N.
)

type PredictorProcess struct {
Ctx context.Context
Client client.SeldonApiClient
Expand Down Expand Up @@ -283,8 +293,7 @@ func (p *PredictorProcess) predictChildren(node *v1.PredictiveUnit, msg payload.
return nil, err
}
var cmsgs []payload.SeldonPayload
if route == -1 {

if route == routeToAllChildren { // Routes msg to all children of the current node.
cmsgs = make([]payload.SeldonPayload, len(node.Children))
var errs = make([]error, len(node.Children))
wg := sync.WaitGroup{}
Expand All @@ -304,13 +313,13 @@ func (p *PredictorProcess) predictChildren(node *v1.PredictiveUnit, msg payload.
return cmsgs[i], err
}
}
} else if route == -2 {
} else if route == routeToNoChildren { // Returns msg as is.
//Abort and return request
p.RoutingMutex.Lock()
p.Routing[node.Name] = -2
p.RoutingMutex.Unlock()
return msg, nil
} else {
} else { // Calls SeldonApiClient.Predict.
cmsgs = make([]payload.SeldonPayload, 1)
cmsgs[0], err = p.Predict(&node.Children[route], msg)
p.RoutingMutex.Lock()
Expand Down

0 comments on commit 472d5dc

Please sign in to comment.