nomad: adding skeleton no-op plan evaluator

This commit is contained in:
Armon Dadgar
2015-07-27 15:31:09 -07:00
parent 6ed85a4dd0
commit 6d402f6652
2 changed files with 30 additions and 1 deletions

View File

@@ -100,7 +100,8 @@ func (s *Server) establishLeadership() error {
// Enable the plan queue, since we are now the leader
s.planQueue.SetEnabled(true)
// TODO: Start the plan evaluator
// Start the plan evaluator
go s.planApply()
// Enable the eval broker, since we are now the leader
s.evalBroker.SetEnabled(true)

28
nomad/plan_apply.go Normal file
View File

@@ -0,0 +1,28 @@
package nomad
import "github.com/hashicorp/nomad/nomad/structs"
// planApply is a long lived goroutine that reads plan allocations from
// the plan queue, determines if they can be applied safely and applies
// them via Raft.
func (s *Server) planApply() {
for {
// Pull the next pending plan, exit if we are no longer leader
pending, err := s.planQueue.Dequeue(0)
if err != nil {
return
}
// TODO: Evaluate the plan
// TODO: Apply the plan
// TODO: Prepare the response
result := &structs.PlanResult{
AllocIndex: 1000,
}
// Respond to the plan
pending.respond(result, nil)
}
}