Documentation ¶
Overview ¶
Package dispatcher models a queue of tasks that are dispatched to a group of pods.
Index ¶
- Constants
- Variables
- func ByGroupID(groupID string) bson.M
- func GetGroupID(t *task.Task) string
- func UpsertOne(query, update interface{}) (*adb.ChangeInfo, error)
- type PodDispatcher
- func Allocate(ctx context.Context, env evergreen.Environment, t *task.Task, p *pod.Pod) (*PodDispatcher, error)
- func Find(q db.Q) ([]PodDispatcher, error)
- func FindOne(q db.Q) (*PodDispatcher, error)
- func FindOneByGroupID(groupID string) (*PodDispatcher, error)
- func FindOneByID(id string) (*PodDispatcher, error)
- func FindOneByPodID(podID string) (*PodDispatcher, error)
- func NewPodDispatcher(groupID string, taskIDs, podIDs []string) PodDispatcher
- func (pd *PodDispatcher) AssignNextTask(ctx context.Context, env evergreen.Environment, p *pod.Pod) (*task.Task, error)
- func (pd *PodDispatcher) Insert() error
- func (pd *PodDispatcher) RemovePod(ctx context.Context, env evergreen.Environment, podID string) error
- func (pd *PodDispatcher) UpsertAtomically() (*adb.ChangeInfo, error)
Constants ¶
const Collection = "pod_dispatchers"
Variables ¶
var ( IDKey = bsonutil.MustHaveTag(PodDispatcher{}, "ID") GroupIDKey = bsonutil.MustHaveTag(PodDispatcher{}, "GroupID") PodIDsKey = bsonutil.MustHaveTag(PodDispatcher{}, "PodIDs") TaskIDsKey = bsonutil.MustHaveTag(PodDispatcher{}, "TaskIDs") ModificationCountKey = bsonutil.MustHaveTag(PodDispatcher{}, "ModificationCount") LastModifiedKey = bsonutil.MustHaveTag(PodDispatcher{}, "LastModified") )
Functions ¶
func GetGroupID ¶
GetGroupID returns the pod dispatcher group ID for the task.
func UpsertOne ¶
func UpsertOne(query, update interface{}) (*adb.ChangeInfo, error)
UpsertOne updates an existing pod dispatcher if it exists based on the query; otherwise, it inserts a new pod dispatcher.
Types ¶
type PodDispatcher ¶
type PodDispatcher struct { // ID is the unique identifier for this dispatcher. ID string `bson:"_id" json:"id"` // GroupID is the unique identifier for the set of tasks that should run in // this dispatcher. GroupID string `bson:"group_id" json:"group_id"` // PodIDs are the identifiers for the pods that run the tasks. PodIDs []string `bson:"pod_ids" json:"pod_ids"` // TaskIDs is the identifiers for the set of tasks to run. TaskIDs []string `bson:"task_ids" json:"task_ids"` // ModificationCount is an incrementing lock used to resolve conflicting // updates to the dispatcher. ModificationCount int `bson:"modification_count" json:"modification_count"` // LastModified is the timestamp when the pod dispatcher was last modified. LastModified time.Time `bson:"last_modified" json:"last_modified"` }
PodDispatcher represents a set of tasks that are dispatched to a set of pods that can run those tasks.
func Allocate ¶
func Allocate(ctx context.Context, env evergreen.Environment, t *task.Task, p *pod.Pod) (*PodDispatcher, error)
Allocate sets up the given intent pod to the given task for dispatching.
func Find ¶
func Find(q db.Q) ([]PodDispatcher, error)
Find finds all pod dispatchers for the given query.
func FindOne ¶
func FindOne(q db.Q) (*PodDispatcher, error)
FindOne finds one pod dispatcher for the given query.
func FindOneByGroupID ¶
func FindOneByGroupID(groupID string) (*PodDispatcher, error)
FindOneByGroupID finds one pod dispatcher by its group ID.
func FindOneByID ¶
func FindOneByID(id string) (*PodDispatcher, error)
FindOneByID finds one pod dispatcher by its ID.
func FindOneByPodID ¶
func FindOneByPodID(podID string) (*PodDispatcher, error)
FindOneByPodID finds the dispatcher that manages the given pod by ID.
func NewPodDispatcher ¶
func NewPodDispatcher(groupID string, taskIDs, podIDs []string) PodDispatcher
NewPodDispatcher returns a new pod dispatcher.
func (*PodDispatcher) AssignNextTask ¶
func (pd *PodDispatcher) AssignNextTask(ctx context.Context, env evergreen.Environment, p *pod.Pod) (*task.Task, error)
AssignNextTask assigns the pod the next available task to run. Returns nil if there's no task available to run. If the pod is already running a task, this will return an error.
func (*PodDispatcher) Insert ¶
func (pd *PodDispatcher) Insert() error
Insert inserts the pod dispatcher into the DB.
func (*PodDispatcher) RemovePod ¶
func (pd *PodDispatcher) RemovePod(ctx context.Context, env evergreen.Environment, podID string) error
RemovePod removes a pod from the dispatcher. If it's the last remaining pod in the dispatcher, it removes all tasks from the dispatcher and marks those tasks as no longer allocated containers.
func (*PodDispatcher) UpsertAtomically ¶
func (pd *PodDispatcher) UpsertAtomically() (*adb.ChangeInfo, error)
UpsertAtomically inserts/updates the pod dispatcher depending on whether the document already exists.