definition

package
v0.0.0-...-be7f909 Latest Latest
Warning

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

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

Documentation

Overview

Package definition contains the data model for the pod definition cache. Pod definitions are templates for creating pods.

Index

Constants

View Source
const Collection = "pod_definitions"
View Source
const PodDefinitionTag = "evergreen-tracked"

PodDefinitionTag is the tag used to track pod definitions.

Variables

View Source
var (
	IDKey           = bsonutil.MustHaveTag(PodDefinition{}, "ID")
	ExternalIDKey   = bsonutil.MustHaveTag(PodDefinition{}, "ExternalID")
	FamilyKey       = bsonutil.MustHaveTag(PodDefinition{}, "Family")
	LastAccessedKey = bsonutil.MustHaveTag(PodDefinition{}, "LastAccessed")
)

Functions

func ByExternalID

func ByExternalID(id string) bson.M

ByExternalID returns a query to find pod definitions with the given external ID.

func ByID

func ByID(id string) bson.M

ByID returns a query to find pod definitions with the given ID.

func UpdateOne

func UpdateOne(query, update interface{}) error

UpdateOne updates an existing pod definition.

func UpsertOne

func UpsertOne(query, update interface{}) (*adb.ChangeInfo, error)

UpsertOne updates an existing pod definition if it exists based on the query; otherwise, it inserts a new pod definition.

Types

type PodDefinition

type PodDefinition struct {
	// ID is the unique identifier for this document.
	ID string `bson:"_id"`
	// ExternalID is the identifier for the template definition in external
	// storage.
	ExternalID string `bson:"external_id,omitempty"`
	// Family is the family name of the pod definition stored in the cloud
	// provider.
	Family string `bson:"family,omitempty"`
	// LastAccessed is the timestamp for the last time this pod definition was
	// used.
	LastAccessed time.Time `bson:"last_accessed,omitempty"`
}

PodDefinition represents a template definition for a pod kept in external storage.

func Find

func Find(q db.Q) ([]PodDefinition, error)

Find finds all pod definitions matching the given query.

func FindByLastAccessedBefore

func FindByLastAccessedBefore(ttl time.Duration, limit int) ([]PodDefinition, error)

FindByLastAccessedBefore finds all pod definitions that were last accessed before the TTL. If a positive limit is given, it will return at most that number of results; otherwise, the results are unlimited.

func FindOne

func FindOne(q db.Q) (*PodDefinition, error)

FindOne finds one pod definition by the given query.

func FindOneByExternalID

func FindOneByExternalID(id string) (*PodDefinition, error)

FindOneByExternalID find a pod definition with the given external ID.

func FindOneByFamily

func FindOneByFamily(family string) (*PodDefinition, error)

FindOneByFamily finds a pod definition with the given family name.

func FindOneID

func FindOneID(id string) (*PodDefinition, error)

FindOneID returns a query to find a pod definition with the given ID.

func (*PodDefinition) Insert

func (pd *PodDefinition) Insert() error

Insert inserts the pod definition into the collection.

func (*PodDefinition) Remove

func (pd *PodDefinition) Remove() error

Remove removes the pod definition from the collection.

func (*PodDefinition) UpdateLastAccessed

func (pd *PodDefinition) UpdateLastAccessed() error

UpdateLastAccessed updates the time this pod definition was last accessed to now.

func (*PodDefinition) Upsert

func (pd *PodDefinition) Upsert() error

Upsert upserts the pod definition into the collection.

type PodDefinitionCache

type PodDefinitionCache struct{}

PodDefinitionCache implements a cocoa.ECSPodDefinitionCache to cache pod definitions in the DB.

func (PodDefinitionCache) Delete

func (pdc PodDefinitionCache) Delete(_ context.Context, externalID string) error

Delete deletes a new pod definition by its external ID. If the pod definition does not exist, this is a no-op.

func (PodDefinitionCache) GetTag

func (pdc PodDefinitionCache) GetTag() string

GetTag returns the tag used for tracking cloud pod definitions.

func (PodDefinitionCache) Put

Put inserts a new pod definition; if an identical one already exists, this is a no-op.

Jump to

Keyboard shortcuts

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