func (s *State) Append(group *mesosfile.Group) {
	s.pending <- group
}
Append pushes the group into the pending chan.
package runner
import (
	"fmt"
	"github.com/mesanine/mesos-cli/mesosfile"
	"github.com/mesos/mesos-go"
)
type ErrTaskTerminal struct {
	task   mesos.TaskID
	status mesos.TaskStatus
}
func (e ErrTaskTerminal) Error() string {
	return fmt.Sprintf(
		"Task %s entered a terminal state %s %s",
		e.task.Value,
		e.status.State.String(),
		e.status.Message,
	)
}
type State struct {
	groups  []*mesosfile.Group
	states  map[string]mesos.TaskState
	pending chan *mesosfile.Group
	updates chan mesos.TaskStatus
	last    mesos.TaskState
	restart bool
	sync    bool
	done    bool
}
func NewState(groups []*mesosfile.Group, restart, sync bool) *State {
	state := &State{
		groups:  groups,
		states:  map[string]mesos.TaskState{},
		pending: make(chan *mesosfile.Group, len(groups)),
		updates: make(chan mesos.TaskStatus),
		restart: restart,
		sync:    sync,
		last:    mesos.TASK_FINISHED,
	}
	for _, group := range groups {
		group.Reset()
		for _, task := range group.Tasks {
			state.states[task.TaskID.Value] = mesos.TaskState(0)
		}
		state.pending <- group
	}
	return state
}
func (s *State) Total() int {
	return len(s.groups)
}
func (s *State) Pop() *mesosfile.Group {
	if s.sync && s.last != mesos.TASK_FINISHED {
		return nil
	}
	select {
	case group := <-s.pending:
		if s.sync {
			s.last = mesos.TaskState(0)
		}
		return group
	default:
	}
	return nil
}