Skip to content

Commit

Permalink
populate count in Eval.List RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Nov 3, 2022
1 parent 721d1c6 commit fa30924
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nomad/eval_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,14 @@ func (e *Eval) List(args *structs.EvalListRequest, reply *structs.EvalListRespon
}

var evals []*structs.Evaluation
count := 0
paginator, err := paginator.NewPaginator(iter, tokenizer, filters, args.QueryOptions,
func(raw interface{}) error {
eval := raw.(*structs.Evaluation)
evals = append(evals, eval)
if !args.CountOnly {
eval := raw.(*structs.Evaluation)
evals = append(evals, eval)
}
count++
return nil
})
if err != nil {
Expand All @@ -706,6 +710,7 @@ func (e *Eval) List(args *structs.EvalListRequest, reply *structs.EvalListRespon

reply.QueryMeta.NextToken = nextToken
reply.Evaluations = evals
reply.Count = count
}

// Use the last index that affected the jobs table
Expand Down
2 changes: 2 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ type EvalDequeueRequest struct {
type EvalListRequest struct {
FilterJobID string
FilterEvalStatus string
CountOnly bool
QueryOptions
}

Expand Down Expand Up @@ -1602,6 +1603,7 @@ type DeploymentListResponse struct {
// EvalListResponse is used for a list request
type EvalListResponse struct {
Evaluations []*Evaluation
Count int
QueryMeta
}

Expand Down

0 comments on commit fa30924

Please sign in to comment.