dispatcher

package
v0.0.0-...-10a60c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package dispatcher models a queue of tasks that are dispatched to a group of pods.

Index

Constants

View Source
const Collection = "pod_dispatchers"

Variables

View Source
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 ByGroupID

func ByGroupID(groupID string) bson.M

ByGroupID returns the query to find a pod dispatcher by its group ID.

func GetGroupID

func GetGroupID(t *task.Task) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL