github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/scheduler/host_allocator.go (about)

     1  package scheduler
     2  
     3  import (
     4  	"github.com/evergreen-ci/evergreen"
     5  	"github.com/evergreen-ci/evergreen/model"
     6  	"github.com/evergreen-ci/evergreen/model/distro"
     7  	"github.com/evergreen-ci/evergreen/model/host"
     8  )
     9  
    10  // HostAllocator is responsible for determining how many new hosts should be spun up.
    11  // Parameters:
    12  //  distros: a map of distro name -> information on that distro (a model.Distro object)
    13  //  existingDistroHosts: a map of distro name -> currently running hosts on that distro
    14  //  taskQueueItems: a map of distro name -> task queue items for that distro (a TaskQueue object)
    15  //  projectTaskDurations: the expected duration of tasks by project and variant
    16  //  taskRunDistros: a map of task id -> distros the task is allowed to run on
    17  // Returns a map of distro name -> how many hosts need to be spun up for that distro.
    18  type HostAllocator interface {
    19  	NewHostsNeeded(allocatorData HostAllocatorData,
    20  		settings *evergreen.Settings) (map[string]int, error)
    21  }
    22  
    23  // HostAllocatorData is the set of parameters passed to a HostAllocator.
    24  type HostAllocatorData struct {
    25  	taskQueueItems       map[string][]model.TaskQueueItem
    26  	existingDistroHosts  map[string][]host.Host
    27  	taskRunDistros       map[string][]string
    28  	distros              map[string]distro.Distro
    29  	projectTaskDurations model.ProjectTaskDurations
    30  }