open-nomad/nomad/plan_endpoint.go
Alex Dadgar 88ddfbed31 Revert "Debug messages around the plan and plan response"
This reverts commit 7646657e6b8a892210779eaf5708341b94b29b24.
2016-02-22 22:24:52 -08:00

39 lines
795 B
Go

package nomad
import (
"time"
"github.com/armon/go-metrics"
"github.com/hashicorp/nomad/nomad/structs"
)
// Plan endpoint is used for plan interactions
type Plan struct {
srv *Server
}
// Submit is used to submit a plan to the leader
func (p *Plan) Submit(args *structs.PlanRequest, reply *structs.PlanResponse) error {
if done, err := p.srv.forward("Plan.Submit", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "plan", "submit"}, time.Now())
// Submit the plan to the queue
future, err := p.srv.planQueue.Enqueue(args.Plan)
if err != nil {
return err
}
// Wait for the results
result, err := future.Wait()
if err != nil {
return err
}
// Package the result
reply.Result = result
reply.Index = result.AllocIndex
return nil
}