instance

package
v0.0.0-...-c009a92 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceExpiration = time.Second * 15
	CacheSyncTime      = time.Minute * 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InstanceCache

type InstanceCache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(analytics analyticscollector.AnalyticsCollectorClient, logger *zap.SugaredLogger, deleteInstance func(data InstanceInfo, purge bool) *api.APIError, initialInstances []*InstanceInfo, counter metric.Int64UpDownCounter) *InstanceCache

func (*InstanceCache) Add

func (c *InstanceCache) Add(instance InstanceInfo) error

Add the instance to the cache and start expiration timer. If the instance already exists we do nothing - it was loaded from Orchestrator.

func (*InstanceCache) Count

func (c *InstanceCache) Count() int

func (*InstanceCache) CountForTeam

func (c *InstanceCache) CountForTeam(teamID uuid.UUID) (count uint)

func (*InstanceCache) Exists

func (c *InstanceCache) Exists(instanceID string) bool

Check if the instance exists in the cache.

func (*InstanceCache) Get

func (c *InstanceCache) Get(instanceID string) (*ttlcache.Item[string, InstanceInfo], error)

Get the item from the cache.

func (*InstanceCache) GetInstance

func (c *InstanceCache) GetInstance(instanceID string) (InstanceInfo, error)

GetInstance from the cache.

func (*InstanceCache) GetInstances

func (c *InstanceCache) GetInstances(teamID *uuid.UUID) (instances []InstanceInfo)

func (*InstanceCache) KeepAliveFor

func (c *InstanceCache) KeepAliveFor(instanceID string, duration time.Duration) error

KeepAliveFor the instance's expiration timer.

func (*InstanceCache) Kill

func (c *InstanceCache) Kill(instanceID string)

Kill the instance and remove it from the cache.

func (*InstanceCache) Reserve

func (c *InstanceCache) Reserve(instanceID string, team uuid.UUID, limit int64) (error, func())

func (*InstanceCache) Sync

func (c *InstanceCache) Sync(instances []*InstanceInfo)

func (*InstanceCache) UpdateCounter

func (c *InstanceCache) UpdateCounter(instance InstanceInfo, value int64)

type InstanceInfo

type InstanceInfo struct {
	Instance          *api.Sandbox
	TeamID            *uuid.UUID
	BuildID           *uuid.UUID
	Metadata          map[string]string
	StartTime         *time.Time
	MaxInstanceLength time.Duration
}

type Reservation

type Reservation struct {
	// contains filtered or unexported fields
}

type ReservationCache

type ReservationCache struct {
	// contains filtered or unexported fields
}

func NewReservationCache

func NewReservationCache() *ReservationCache

Jump to

Keyboard shortcuts

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