types

package
v0.0.0-...-71b633e Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenTypeClusterAdmin string = "admin"
	TokenTypeWorkspace    string = "workspace"
	TokenTypeWorker       string = "worker"
	TokenTypeMachine      string = "machine"
)
View Source
const (
	StubTypeFunction            string = "function"
	StubTypeFunctionDeployment  string = "function/deployment"
	StubTypeFunctionServe       string = "function/serve"
	StubTypeTaskQueue           string = "taskqueue"
	StubTypeTaskQueueDeployment string = "taskqueue/deployment"
	StubTypeTaskQueueServe      string = "taskqueue/serve"
	StubTypeEndpoint            string = "endpoint"
	StubTypeEndpointDeployment  string = "endpoint/deployment"
	StubTypeEndpointServe       string = "endpoint/serve"
)
View Source
const (
	DefaultExtractedObjectPath         string        = "/data/unpacked"
	DefaultVolumesPath                 string        = "/data/volumes"
	DefaultObjectPath                  string        = "/data/objects"
	DefaultOutputsPath                 string        = "/data/outputs"
	DefaultFilesystemName              string        = "beta9-fs"
	DefaultFilesystemPath              string        = "/data"
	FailedDeploymentContainerThreshold int           = 3
	FailedContainerThreshold           int           = 1
	RequestTimeoutDurationS            time.Duration = 175 * time.Second
	ContainerVolumePath                string        = "/volumes"
)
View Source
const (
	MachineStatusRegistered          MachineStatus = "registered"
	MachineStatusPending             MachineStatus = "pending"
	MachinePendingExpirationS        int           = 3600 // 1 hour
	MachineKeepaliveExpirationS      int           = 60   // 1 minute
	MachineEmptyConsolidationPeriodM time.Duration = 10 * time.Minute
)
View Source
const (
	WorkerStatusAvailable WorkerStatus = "available"
	WorkerStatusPending   WorkerStatus = "pending"
	WorkerStateTtlS       int          = 60
)
View Source
const (
	ContainerDurationEmissionInterval      time.Duration = 5 * time.Second
	ContainerResourceUsageEmissionInterval time.Duration = 3 * time.Second
)
View Source
const (
	WorkerLifecycleStatsKey        string        = "beta9.worker.usage.spawner.lifecycle"
	WorkerDurationStatsKey         string        = "beta9.worker.usage.spawner.duration"
	WorkerUserCodeVolume           string        = "/mnt/code"
	WorkerUserOutputVolume         string        = "/data/outputs"
	WorkerDurationEmissionInterval time.Duration = 30 * time.Second
	WorkerKeepAliveInterval        time.Duration = 15 * time.Second
)
View Source
const ContainerExitCodeTtlS int = 300
View Source
const ContainerStateTtlS int = 60
View Source
const ContainerStateTtlSWhilePending int = 600
View Source
const WorkspaceQuotaTtlS int = 600

Variables

View Source
var (
	EventContainerLifecycle = "container.lifecycle"
	EventWorkerLifecycle    = "worker.lifecycle"
)
View Source
var (
	EventContainerLifecycleRequested = "requested"
	EventContainerLifecycleScheduled = "scheduled"
	EventContainerLifecycleStarted   = "started"
	EventContainerLifecycleStopped   = "stopped"
	EventContainerLifecycleFailed    = "failed"
)
View Source
var (
	EventWorkerLifecycleStarted = "started"
	EventWorkerLifecycleStopped = "stopped"
)
View Source
var (
	// Scheduler keys
	MetricsSchedulerContainerScheduled = "container_scheduled_count"
	MetricsSchedulerContainerRequested = "container_requested_count"

	// Worker keys
	MetricsWorkerContainerDuration = "container_duration_milliseconds"
)
View Source
var DefaultTaskPolicy = TaskPolicy{
	MaxRetries: 3,
	Timeout:    3600,
}
View Source
var EventContainerLifecycleSchemaVersion = "1.0"
View Source
var EventContainerStatusRequestedSchemaVersion = "1.0"
View Source
var EventWorkerLifecycleSchemaVersion = "1.0"

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	ClusterName    string               `key:"clusterName" json:"cluster_name"`
	DebugMode      bool                 `key:"debugMode" json:"debug_mode"`
	Database       DatabaseConfig       `key:"database" json:"database"`
	GatewayService GatewayServiceConfig `key:"gateway" json:"gateway_service"`
	ImageService   ImageServiceConfig   `key:"imageservice" json:"image_service"`
	Storage        StorageConfig        `key:"storage" json:"storage"`
	Worker         WorkerConfig         `key:"worker" json:"worker"`
	Providers      ProviderConfig       `key:"providers" json:"providers"`
	Tailscale      TailscaleConfig      `key:"tailscale" json:"tailscale"`
	Proxy          ProxyConfig          `key:"proxy" json:"proxy"`
	Monitoring     MonitoringConfig     `key:"monitoring" json:"monitoring"`
}

type AvailableHost

type AvailableHost struct {
	Hostname    string
	ContainerId string
}

type BaseFilter

type BaseFilter struct {
	Limit  uint32 `query:"limit"`
	Offset int    `query:"offset"`
}

type CORSConfig

type CORSConfig struct {
	AllowedOrigins []string `key:"allowOrigins" json:"allow_origins"`
	AllowedMethods []string `key:"allowMethods" json:"allow_methods"`
	AllowedHeaders []string `key:"allowHeaders" json:"allow_headers"`
}

type CapacityUpdateType

type CapacityUpdateType int
const (
	AddCapacity CapacityUpdateType = iota
	RemoveCapacity
)

type ConcurrencyLimit

type ConcurrencyLimit struct {
	Id                uint      `db:"id" json:"-" redis:"-"`
	ExternalId        string    `db:"external_id" json:"external_id,omitempty" redis:"external_id"`
	GPULimit          uint32    `db:"gpu_limit" json:"gpu_limit" redis:"gpu_limit"`
	CPUMillicoreLimit uint32    `db:"cpu_millicore_limit" json:"cpu_millicore_limit" redis:"cpu_millicore_limit"`
	CreatedAt         time.Time `db:"created_at" json:"created_at,omitempty" redis:"-"`
	UpdatedAt         time.Time `db:"updated_at" json:"updated_at,omitempty" redis:"-"`
}

type ContainerAlreadyScheduledError

type ContainerAlreadyScheduledError struct {
	Msg string
}

func (*ContainerAlreadyScheduledError) Error

type ContainerEvent

type ContainerEvent struct {
	ContainerId string
	Change      int
}

type ContainerRequest

type ContainerRequest struct {
	ContainerId  string    `json:"container_id"`
	EntryPoint   []string  `json:"entry_point"`
	Env          []string  `json:"env"`
	Cpu          int64     `json:"cpu"`
	Memory       int64     `json:"memory"`
	Gpu          string    `json:"gpu"`
	GpuCount     uint32    `json:"gpu_count"`
	SourceImage  *string   `json:"source_image"`
	ImageId      string    `json:"image_id"`
	StubId       string    `json:"stub_id"`
	WorkspaceId  string    `json:"workspace_id"`
	Timestamp    time.Time `json:"timestamp"`
	Mounts       []Mount   `json:"mounts"`
	RetryCount   int       `json:"retry_count"`
	PoolSelector string    `json:"pool_selector"`
}

type ContainerResourceUsage

type ContainerResourceUsage struct {
	ContainerID       string `json:"ContainerID"`
	CpuMillicoresUsed int64  `json:"CpuMillicoresUsed"`
	MemoryUsed        int    `json:"MemoryUsed"`
	GpuMemoryUsed     int64  `json:"GpuMemoryUsed"`
	GpuMemoryTotal    int64  `json:"GpuMemoryTotal"`
	GpuType           string `json:"GpuType"`
}

type ContainerState

type ContainerState struct {
	ContainerId string          `redis:"container_id" json:"container_id"`
	StubId      string          `redis:"stub_id" json:"stub_id"`
	Status      ContainerStatus `redis:"status" json:"status"`
	ScheduledAt int64           `redis:"scheduled_at" json:"scheduled_at"`
	WorkspaceId string          `redis:"workspace_id" json:"workspace_id"`
	Gpu         string          `redis:"gpu" json:"gpu"`
	GpuCount    uint32          `redis:"gpu_count" json:"gpu_count"`
	Cpu         int64           `redis:"cpu" json:"cpu"`
	Memory      int64           `redis:"memory" json:"memory"`
}

type ContainerStatus

type ContainerStatus string
const (
	ContainerStatusPending  ContainerStatus = "PENDING"
	ContainerStatusRunning  ContainerStatus = "RUNNING"
	ContainerStatusStopping ContainerStatus = "STOPPING"
)

type DatabaseConfig

type DatabaseConfig struct {
	Redis    RedisConfig    `key:"redis" json:"redis"`
	Postgres PostgresConfig `key:"postgres" json:"postgres"`
}

type Deployment

type Deployment struct {
	Id          uint      `db:"id" json:"id"`
	ExternalId  string    `db:"external_id" json:"external_id"`
	Name        string    `db:"name" json:"name"`
	Active      bool      `db:"active" json:"active"`
	WorkspaceId uint      `db:"workspace_id" json:"workspace_id"` // Foreign key to Workspace
	StubId      uint      `db:"stub_id" json:"stub_id"`           // Foreign key to Stub
	StubType    string    `db:"stub_type" json:"stub_type"`
	Version     uint      `db:"version" json:"version"`
	CreatedAt   time.Time `db:"created_at" json:"created_at"`
	UpdatedAt   time.Time `db:"updated_at" json:"updated_at"`
}

type DeploymentFilter

type DeploymentFilter struct {
	BaseFilter
	StubIds        StringSlice `query:"stub_ids"`
	WorkspaceID    uint        `query:"workspace_id"`
	StubType       string      `query:"stub_type"`
	Name           string      `query:"name"`
	Active         *bool       `query:"active"`
	Version        uint        `query:"version"`
	Cursor         string      `query:"cursor"`
	CreatedAtStart string      `query:"created_at_start"`
	CreatedAtEnd   string      `query:"created_at_end"`
	Pagination     bool        `query:"pagination"`
}

type DeploymentWithRelated

type DeploymentWithRelated struct {
	Deployment
	Workspace Workspace `db:"workspace" json:"workspace"`
	Stub      Stub      `db:"stub" json:"stub"`
}

type DockerImageRegistryConfig

type DockerImageRegistryConfig struct {
	Username string `key:"username" json:"username"`
	Password string `key:"password" json:"password"`
}

type EC2ProviderConfig

type EC2ProviderConfig struct {
	AWSAccessKey string  `key:"awsAccessKey" json:"aws_access_key"`
	AWSSecretKey string  `key:"awsSecretKey" json:"aws_secret_key"`
	AWSRegion    string  `key:"awsRegion" json:"aws_region"`
	AMI          string  `key:"ami" json:"ami"`
	SubnetId     *string `key:"subnetId" json:"subnet_id"`
}

type ErrContainerStateNotFound

type ErrContainerStateNotFound struct {
	ContainerId string
}

func (*ErrContainerStateNotFound) Error

func (e *ErrContainerStateNotFound) Error() string

type ErrInvalidWorkerStatus

type ErrInvalidWorkerStatus struct {
}

func (*ErrInvalidWorkerStatus) Error

func (e *ErrInvalidWorkerStatus) Error() string

type ErrNoSuitableWorkerFound

type ErrNoSuitableWorkerFound struct {
}

func (*ErrNoSuitableWorkerFound) Error

func (e *ErrNoSuitableWorkerFound) Error() string

type ErrWorkerNotFound

type ErrWorkerNotFound struct {
	WorkerId string
}

func (*ErrWorkerNotFound) Error

func (e *ErrWorkerNotFound) Error() string

type EventClient

type EventClient interface {
	PushEvent(event cloudevents.Event) error
}

type EventContainerLifecycleSchema

type EventContainerLifecycleSchema struct {
	ContainerID string `json:"container_id"`
	WorkerID    string `json:"worker_id"`
	Status      string `json:"status"`
}

type EventContainerStatusRequestedSchema

type EventContainerStatusRequestedSchema struct {
	ContainerID string           `json:"container_id"`
	Request     ContainerRequest `json:"request"`
	Status      string           `json:"status"`
}

type EventSink

type EventSink = func(event []cloudevents.Event)

type EventWorkerLifecycleSchema

type EventWorkerLifecycleSchema struct {
	WorkerID string `json:"worker_id"`
	Status   string `json:"status"`
}

type FilterFieldMapping

type FilterFieldMapping struct {
	ClientField   string
	ClientValues  []string
	DatabaseField string
}

FilterFieldMapping represents a mapping between a client-provided field and its corresponding database field, along with the values for filtering on the database field.

type FluentBitConfig

type FluentBitConfig struct {
	Events FluentBitEventConfig `key:"events"`
}

type FluentBitEventConfig

type FluentBitEventConfig struct {
	Endpoint        string        `key:"endpoint"`
	MaxConns        int           `key:"maxConns"`
	MaxIdleConns    int           `key:"maxIdleConns"`
	IdleConnTimeout time.Duration `key:"idleConnTimeout"`
	DialTimeout     time.Duration `key:"dialTimeout"`
	KeepAlive       time.Duration `key:"keepAlive"`
}

type GPUType

type GPUType string
const (
	GPU_A10G    GPUType = "A10G"
	GPU_A100_40 GPUType = "A100-40"
	GPU_A100_80 GPUType = "A100-80"
	GPU_L4      GPUType = "L4"
	GPU_T4      GPUType = "T4"

	NO_GPU GPUType = "NO_GPU"
)

func (GPUType) String

func (g GPUType) String() string

type GRPCConfig

type GRPCConfig struct {
	Port           int `key:"port" json:"port"`
	MaxRecvMsgSize int `key:"maxRecvMsgSize" json:"max_recv_msg_size"`
	MaxSendMsgSize int `key:"maxSendMsgSize" json:"max_send_msg_size"`
}

type GatewayServiceConfig

type GatewayServiceConfig struct {
	Host            string        `key:"host" json:"host"`
	ExternalURL     string        `key:"externalURL" json:"external_url"`
	GRPC            GRPCConfig    `key:"grpc" json:"grpc"`
	HTTP            HTTPConfig    `key:"http" json:"http"`
	ShutdownTimeout time.Duration `key:"shutdownTimeout" json:"shutdown_timeout"`
}

type GpuType

type GpuType string

func (*GpuType) UnmarshalJSON

func (g *GpuType) UnmarshalJSON(data []byte) error

type HTTPConfig

type HTTPConfig struct {
	EnablePrettyLogs bool       `key:"enablePrettyLogs" json:"enable_pretty_logs"`
	CORS             CORSConfig `key:"cors" json:"cors"`
	Port             int        `key:"port" json:"port"`
}

type Image

type Image struct {
	Commands             []string `json:"commands"`
	PythonVersion        string   `json:"python_version"`
	PythonPackages       []string `json:"python_packages"`
	BaseImage            *string  `json:"base_image"`
	BaseImageCredentials *string  `json:"base_image_creds"`
}

type ImageRegistriesConfig

type ImageRegistriesConfig struct {
	Docker DockerImageRegistryConfig `key:"docker" json:"docker"`
	S3     S3ImageRegistryConfig     `key:"s3" json:"s3"`
}

type ImageServiceConfig

type ImageServiceConfig struct {
	CacheURL                       string                `key:"cacheURL" json:"cache_url"`
	RegistryStore                  string                `key:"registryStore" json:"registry_store"`
	RegistryCredentialProviderName string                `key:"registryCredentialProvider" json:"registry_credential_provider_name"`
	Registries                     ImageRegistriesConfig `key:"registries" json:"registries"`
	LocalCacheEnabled              bool                  `key:"localCacheEnabled" json:"local_cache_enabled"`
	EnableTLS                      bool                  `key:"enableTLS" json:"enable_tls"`
	BuildContainerCpu              int64                 `key:"buildContainerCpu" json:"build_container_cpu"`
	BuildContainerMemory           int64                 `key:"buildContainerMemory" json:"build_container_memory"`
	BuildContainerPoolSelector     string                `key:"buildContainerPoolSelector" json:"build_container_pool_selector"`
	Runner                         RunnerConfig          `key:"runner" json:"runner"`
}

type InternalService

type InternalService struct {
	Name        string `key:"name" json:"name"`
	LocalPort   int    `key:"localPort" json:"local_port"`
	Destination string `key:"destination" json:"destination"`
}

type JuiceFSConfig

type JuiceFSConfig struct {
	RedisURI     string `key:"redisURI" json:"redis_uri"`
	AWSS3Bucket  string `key:"awsS3Bucket" json:"aws_s3_bucket"`
	AWSAccessKey string `key:"awsAccessKey" json:"aws_access_key"`
	AWSSecretKey string `key:"awsSecretKey" json:"aws_secret_key"`
	CacheSize    int64  `key:"cacheSize" json:"cache_size"`
	BlockSize    int64  `key:"blockSize" json:"block_size"`
	Prefetch     int64  `key:"prefetch" json:"prefetch"`
	BufferSize   int64  `key:"bufferSize" json:"buffer_size"`
}

type LambdaLabsProviderConfig

type LambdaLabsProviderConfig struct {
	ApiKey string `key:"apiKey" json:"apiKey"`
}

type MachineProvider

type MachineProvider string
var (
	ProviderEC2        MachineProvider = "ec2"
	ProviderOCI        MachineProvider = "oci"
	ProviderLambdaLabs MachineProvider = "lambda"
)

type MachineStatus

type MachineStatus string

type MetricsCollector

type MetricsCollector string
var (
	MetricsCollectorPrometheus MetricsCollector = "prometheus"
	MetricsCollectorOpenMeter  MetricsCollector = "openmeter"
)

type MonitoringConfig

type MonitoringConfig struct {
	MetricsCollector string           `key:"metricsCollector" json:"metrics_collector"`
	Prometheus       PrometheusConfig `key:"prometheus" json:"prometheus"`
	OpenMeter        OpenMeterConfig  `key:"openmeter" json:"openmeter"`
	FluentBit        FluentBitConfig  `key:"fluentbit" json:"fluentbit"`
}

type Mount

type Mount struct {
	LocalPath string `json:"local_path"`
	MountPath string `json:"mount_path"`
	LinkPath  string `json:"link_path"`
	ReadOnly  bool   `json:"read_only"`
}

type MountPointConfig

type MountPointConfig struct {
	AWSS3Bucket  string `key:"awsS3Bucket" json:"aws_s3_bucket"`
	AWSAccessKey string `key:"awsAccessKey" json:"aws_access_key"`
	AWSSecretKey string `key:"awsSecretKey" json:"aws_secret_key"`
}

type OCIProviderConfig

type OCIProviderConfig struct {
	Tenancy            string `key:"tenancy" json:"tenancy"`
	UserId             string `key:"userId" json:"user_id"`
	Region             string `key:"region" json:"region"`
	FingerPrint        string `key:"fingerprint" json:"fingerprint"`
	PrivateKey         string `key:"privateKey" json:"private_key"`
	PrivateKeyPassword string `key:"privateKeyPassword" json:"private_key_password"`
	CompartmentId      string `key:"compartmentId" json:"compartment_id"`
	SubnetId           string `key:"subnetId" json:"subnet_id"`
	AvailabilityDomain string `key:"availabilityDomain" json:"availability_domain"`
	ImageId            string `key:"imageId" json:"image_id"`
}

type Object

type Object struct {
	Id          uint      `db:"id" json:"id"`
	ExternalId  string    `db:"external_id" json:"external_id"`
	Hash        string    `db:"hash" json:"hash"`
	Size        int64     `db:"size" json:"size"`
	WorkspaceId uint      `db:"workspace_id" json:"workspace_id"` // Foreign key to Workspace
	CreatedAt   time.Time `db:"created_at" json:"created_at"`
}

type OpenMeterConfig

type OpenMeterConfig struct {
	ServerUrl string `key:"serverUrl" json:"server_url"`
	ApiKey    string `key:"apiKey" json:"api_key"`
}

type PoolMode

type PoolMode string
var (
	PoolModeLocal    PoolMode = "local"
	PoolModeExternal PoolMode = "external"
)

type PostgresConfig

type PostgresConfig struct {
	Host      string `key:"host" json:"host"`
	Port      int    `key:"port" json:"port"`
	Name      string `key:"name" json:"name"`
	Username  string `key:"username" json:"username"`
	Password  string `key:"password" json:"password"`
	TimeZone  string `key:"timezone" json:"timezone"`
	EnableTLS bool   `key:"enableTLS" json:"enable_tls"`
}

type PrometheusConfig

type PrometheusConfig struct {
	ScrapeWorkers bool `key:"scrapeWorkers" json:"scrape_workers"`
	Port          int  `key:"port" json:"port"`
}

type ProviderComputeRequest

type ProviderComputeRequest struct {
	Cpu      int64
	Memory   int64
	Gpu      string
	GpuCount uint32
}

type ProviderConfig

type ProviderConfig struct {
	EC2Config        EC2ProviderConfig        `key:"ec2" json:"ec2"`
	OCIConfig        OCIProviderConfig        `key:"oci" json:"oci"`
	LambdaLabsConfig LambdaLabsProviderConfig `key:"lambda" json:"lambda"`
}

type ProviderMachine

type ProviderMachine struct {
	State *ProviderMachineState
}

type ProviderMachineState

type ProviderMachineState struct {
	MachineId         string        `json:"machine_id" redis:"machine_id"`
	PoolName          string        `json:"pool_name" redis:"pool_name"`
	Status            MachineStatus `json:"status" redis:"status"`
	HostName          string        `json:"hostname" redis:"hostname"`
	Token             string        `json:"token" redis:"token"`
	Cpu               int64         `json:"cpu" redis:"cpu"`
	Memory            int64         `json:"memory" redis:"memory"`
	Gpu               string        `json:"gpu" redis:"gpu"`
	GpuCount          uint32        `json:"gpu_count" redis:"gpu_count"`
	RegistrationToken string        `json:"registration_token" redis:"registration_token"`
	Created           string        `json:"created" redis:"created"`
	LastWorkerSeen    string        `json:"last_worker_seen" redis:"last_worker_seen"`
	LastKeepalive     string        `json:"last_keepalive" redis:"last_keepalive"`
	AutoConsolidate   bool          `json:"auto_consolidate" redis:"auto_consolidate"`
}

type ProxyConfig

type ProxyConfig struct {
	HTTPPort int               `key:"httpPort" json:"http_port"`
	Services []InternalService `key:"services" json:"services"`
}

type QuotaDoesNotExistError

type QuotaDoesNotExistError struct{}

func (*QuotaDoesNotExistError) Error

func (e *QuotaDoesNotExistError) Error() string

type RedisConfig

type RedisConfig struct {
	Addrs              []string      `key:"addrs" json:"addrs"`
	Mode               RedisMode     `key:"mode" json:"mode"`
	ClientName         string        `key:"clientName" json:"client_name"`
	EnableTLS          bool          `key:"enableTLS" json:"enable_tls"`
	InsecureSkipVerify bool          `key:"insecureSkipVerify" json:"insecure_skip_verify"`
	MinIdleConns       int           `key:"minIdleConns" json:"min_idle_conns"`
	MaxIdleConns       int           `key:"maxIdleConns" json:"max_idle_conns"`
	ConnMaxIdleTime    time.Duration `key:"connMaxIdleTime" json:"conn_max_idle_time"`
	ConnMaxLifetime    time.Duration `key:"connMaxLifetime" json:"conn_max_lifetime"`
	DialTimeout        time.Duration `key:"dialTimeout" json:"dial_timeout"`
	ReadTimeout        time.Duration `key:"readTimeout" json:"read_timeout"`
	WriteTimeout       time.Duration `key:"writeTimeout" json:"write_timeout"`
	MaxRedirects       int           `key:"maxRedirects" json:"max_redirects"`
	MaxRetries         int           `key:"maxRetries" json:"max_retries"`
	PoolSize           int           `key:"poolSize" json:"pool_size"`
	Username           string        `key:"username" json:"username"`
	Password           string        `key:"password" json:"password"`
	RouteByLatency     bool          `key:"routeByLatency" json:"route_by_latency"`
}

type RedisMode

type RedisMode string
var (
	RedisModeSingle  RedisMode = "single"
	RedisModeCluster RedisMode = "cluster"
)

type RunnerConfig

type RunnerConfig struct {
	BaseImageName     string            `key:"baseImageName" json:"base_image_name"`
	BaseImageRegistry string            `key:"baseImageRegistry" json:"base_image_registry"`
	BaseImageTag      string            `key:"baseImageTag" json:"base_image_tag"`
	Tags              map[string]string `key:"tags" json:"tags"`
}

type Runtime

type Runtime struct {
	Cpu     int64   `json:"cpu"`
	Gpu     GpuType `json:"gpu"`
	Memory  int64   `json:"memory"`
	ImageId string  `json:"image_id"`
}

type S3ImageRegistryConfig

type S3ImageRegistryConfig struct {
	BucketName string `key:"bucketName" json:"bucket_name"`
	AccessKey  string `key:"accessKey" json:"access_key"`
	SecretKey  string `key:"secretKey" json:"secret_key"`
	Region     string `key:"region" json:"region"`
	Endpoint   string `key:"endpoint" json:"endpoint"`
}

type Secret

type Secret struct {
	Id            uint      `db:"id" json:"-"`
	ExternalId    string    `db:"external_id" json:"external_id,omitempty"`
	CreatedAt     time.Time `db:"created_at" json:"created_at,omitempty"`
	UpdatedAt     time.Time `db:"updated_at" json:"updated_at,omitempty"`
	Name          string    `db:"name" json:"name"`
	Value         string    `db:"value" json:"value,omitempty"`
	WorkspaceId   uint      `db:"workspace_id" json:"workspace_id"`
	LastUpdatedBy *uint     `db:"last_updated_by" json:"last_updated_by"`
}

type StorageConfig

type StorageConfig struct {
	Mode           string           `key:"mode" json:"mode"`
	FilesystemName string           `key:"fsName" json:"filesystem_name"`
	FilesystemPath string           `key:"fsPath" json:"filesystem_path"`
	ObjectPath     string           `key:"objectPath" json:"object_path"`
	JuiceFS        JuiceFSConfig    `key:"juicefs" json:"juicefs"`
	MountPoint     MountPointConfig `key:"mountpoint" json:"mountpoint"`
}

type StringSlice

type StringSlice []string

Custom type for a slice of strings

func (*StringSlice) UnmarshalParam

func (s *StringSlice) UnmarshalParam(src string) error

UnmarshalParam implements the echo query parameter unmarshaler interface

type Stub

type Stub struct {
	Id            uint      `db:"id" json:"id"`
	ExternalId    string    `db:"external_id" json:"external_id"`
	Name          string    `db:"name" json:"name"`
	Type          StubType  `db:"type" json:"type"`
	Config        string    `db:"config" json:"config"`
	ConfigVersion uint      `db:"config_version" json:"config_version"`
	ObjectId      uint      `db:"object_id" json:"object_id"`       // Foreign key to Object
	WorkspaceId   uint      `db:"workspace_id" json:"workspace_id"` // Foreign key to Workspace
	CreatedAt     time.Time `db:"created_at" json:"created_at"`
	UpdatedAt     time.Time `db:"updated_at" json:"updated_at"`
}

type StubConfigV1

type StubConfigV1 struct {
	Runtime         Runtime      `json:"runtime"`
	Handler         string       `json:"handler"`
	OnStart         string       `json:"on_start"`
	PythonVersion   string       `json:"python_version"`
	KeepWarmSeconds uint         `json:"keep_warm_seconds"`
	MaxPendingTasks uint         `json:"max_pending_tasks"`
	CallbackUrl     string       `json:"callback_url"`
	TaskPolicy      TaskPolicy   `json:"task_policy"`
	Concurrency     uint         `json:"concurrency"`
	Authorized      bool         `json:"authorized"`
	MaxContainers   uint         `json:"max_containers"`
	Volumes         []*pb.Volume `json:"volumes"`
	Secrets         []Secret     `json:"secrets"`
}

type StubFilter

type StubFilter struct {
	WorkspaceID string      `query:"workspace_id"`
	StubIds     StringSlice `query:"stub_ids"` // The query parameter name is "values"
}

Struct that includes the custom type

type StubType

type StubType string

func (StubType) IsDeployment

func (t StubType) IsDeployment() bool

func (StubType) IsServe

func (t StubType) IsServe() bool

type StubWithRelated

type StubWithRelated struct {
	Stub
	Workspace Workspace `db:"workspace" json:"workspace"`
	Object    Object    `db:"object" json:"object"`
}

type TailscaleConfig

type TailscaleConfig struct {
	ControlURL string `key:"controlUrl" json:"control_url"`
	User       string `key:"user" json:"user"`
	AuthKey    string `key:"authKey" json:"auth_key"`
	HostName   string `key:"hostName" json:"host_name"`
	Enabled    bool   `key:"enabled" json:"enabled"`
	Debug      bool   `key:"debug" json:"debug"`
}

type Task

type Task struct {
	Id          uint         `db:"id" json:"id,omitempty"`
	ExternalId  string       `db:"external_id" json:"external_id,omitempty"`
	Status      TaskStatus   `db:"status" json:"status,omitempty"`
	ContainerId string       `db:"container_id" json:"container_id,omitempty"`
	StartedAt   sql.NullTime `db:"started_at" json:"started_at,omitempty"`
	EndedAt     sql.NullTime `db:"ended_at" json:"ended_at,omitempty"`
	WorkspaceId uint         `db:"workspace_id" json:"workspace_id,omitempty"` // Foreign key to Workspace
	StubId      uint         `db:"stub_id" json:"stub_id,omitempty"`           // Foreign key to Stub
	CreatedAt   time.Time    `db:"created_at" json:"created_at,omitempty"`
	UpdatedAt   time.Time    `db:"updated_at" json:"updated_at,omitempty"`
}

type TaskCancellationReason

type TaskCancellationReason string
const (
	TaskExpired            TaskCancellationReason = "expired"
	TaskExceededRetryLimit TaskCancellationReason = "exceeded_retry_limit"
)

type TaskCountByTime

type TaskCountByTime struct {
	Time         time.Time       `db:"time" json:"time"`
	Count        uint            `count:"count" json:"count"`
	StatusCounts json.RawMessage `db:"status_counts" json:"status_counts"`
}

type TaskCountPerDeployment

type TaskCountPerDeployment struct {
	DeploymentName string `db:"deployment_name" json:"deployment_name"`
	TaskCount      uint   `db:"task_count" json:"task_count"`
}

type TaskExecutor

type TaskExecutor string
var (
	ExecutorTaskQueue TaskExecutor = "taskqueue"
	ExecutorEndpoint  TaskExecutor = "endpoint"
	ExecutorFunction  TaskExecutor = "function"
	ExecutorContainer TaskExecutor = "container"
)

type TaskFilter

type TaskFilter struct {
	BaseFilter
	WorkspaceID    uint        `query:"workspace_id"`
	TaskId         string      `query:"task_id"`
	StubType       string      `query:"stub_type"`
	StubIds        StringSlice `query:"stub_ids"`
	Status         string      `query:"status"`
	CreatedAtStart string      `query:"created_at_start"`
	CreatedAtEnd   string      `query:"created_at_end"`
	MinDuration    uint        `query:"min_duration"`
	MaxDuration    uint        `query:"max_duration"`
	Cursor         string      `query:"cursor"`
}

type TaskInterface

type TaskInterface interface {
	Execute(ctx context.Context, options ...interface{}) error
	Cancel(ctx context.Context, reason TaskCancellationReason) error
	Retry(ctx context.Context) error
	HeartBeat(ctx context.Context) (bool, error)
	Metadata() TaskMetadata
}

type TaskMessage

type TaskMessage struct {
	TaskId        string                 `json:"task_id" redis:"task_id"`
	WorkspaceName string                 `json:"workspace_name" redis:"workspace_name"`
	StubId        string                 `json:"stub_id" redis:"stub_id"`
	Executor      string                 `json:"executor" redis:"executor"`
	Args          []interface{}          `json:"args" redis:"args"`
	Kwargs        map[string]interface{} `json:"kwargs" redis:"kwargs"`
	Policy        TaskPolicy             `json:"policy" redis:"policy"`
	Retries       uint                   `json:"retries" redis:"retries"`
	Timestamp     int64                  `json:"timestamp" redis:"timestamp"`
}

TaskMessage represents a JSON serializable message to be added to the queue

func (*TaskMessage) Decode

func (tm *TaskMessage) Decode(encodedData []byte) error

Decode initializes the TaskMessage fields from a byte array

func (*TaskMessage) Encode

func (tm *TaskMessage) Encode() ([]byte, error)

Encode returns a binary representation of the TaskMessage

func (*TaskMessage) Reset

func (tm *TaskMessage) Reset()

type TaskMetadata

type TaskMetadata struct {
	TaskId        string
	StubId        string
	WorkspaceName string
	ContainerId   string
}

type TaskParams

type TaskParams struct {
	TaskId      string
	ContainerId string
	StubId      uint
	WorkspaceId uint
}

type TaskPayload

type TaskPayload struct {
	Args   []interface{}          `json:"args"`
	Kwargs map[string]interface{} `json:"kwargs"`
}

type TaskPolicy

type TaskPolicy struct {
	MaxRetries uint      `json:"max_retries" redis:"max_retries"`
	Timeout    int       `json:"timeout" redis:"timeout"`
	Expires    time.Time `json:"expires" redis:"expires"`
}

type TaskStatus

type TaskStatus string
const (
	TaskStatusPending   TaskStatus = "PENDING"
	TaskStatusRunning   TaskStatus = "RUNNING"
	TaskStatusComplete  TaskStatus = "COMPLETE"
	TaskStatusError     TaskStatus = "ERROR"
	TaskStatusCancelled TaskStatus = "CANCELLED"
	TaskStatusTimeout   TaskStatus = "TIMEOUT"
	TaskStatusRetry     TaskStatus = "RETRY"
)

func (TaskStatus) IsCompleted

func (ts TaskStatus) IsCompleted() bool

type TaskWithRelated

type TaskWithRelated struct {
	Task
	Workspace Workspace `db:"workspace" json:"workspace"`
	Stub      Stub      `db:"stub" json:"stub"`
}

type ThrottledByConcurrencyLimitError

type ThrottledByConcurrencyLimitError struct {
	Reason string
}

func (*ThrottledByConcurrencyLimitError) Error

type Token

type Token struct {
	Id          uint       `db:"id" json:"id"`
	ExternalId  string     `db:"external_id" json:"external_id"`
	Key         string     `db:"key" json:"key"`
	Active      bool       `db:"active" json:"active"`
	Reusable    bool       `db:"reusable" json:"reusable"`
	WorkspaceId *uint      `db:"workspace_id" json:"workspace_id,omitempty"` // Foreign key to Workspace
	Workspace   *Workspace `db:"workspace" json:"workspace,omitempty"`       // Pointer to associated Workspace
	TokenType   string     `db:"token_type" json:"token_type"`
	CreatedAt   time.Time  `db:"created_at" json:"created_at"`
	UpdatedAt   time.Time  `db:"updated_at" json:"updated_at"`
}

type Volume

type Volume struct {
	Id          uint      `db:"id" json:"id"`
	ExternalId  string    `db:"external_id" json:"external_id"`
	Name        string    `db:"name" json:"name"`
	Size        uint64    `json:"size"`                           // Populated by volume abstraction
	WorkspaceId uint      `db:"workspace_id" json:"workspace_id"` // Foreign key to Workspace
	CreatedAt   time.Time `db:"created_at" json:"created_at"`
	UpdatedAt   time.Time `db:"updated_at" json:"updated_at"`
}

type VolumeWithRelated

type VolumeWithRelated struct {
	Volume
	Workspace Workspace `db:"workspace" json:"workspace"`
}

type Worker

type Worker struct {
	Id                   string       `json:"id" redis:"id"`
	Status               WorkerStatus `json:"status" redis:"status"`
	TotalCpu             int64        `json:"total_cpu" redis:"total_cpu"`
	TotalMemory          int64        `json:"total_memory" redis:"total_memory"`
	TotalGpuCount        uint32       `json:"total_gpu_count" redis:"total_gpu_count"`
	FreeCpu              int64        `json:"free_cpu" redis:"free_cpu"`
	FreeMemory           int64        `json:"free_memory" redis:"free_memory"`
	FreeGpuCount         uint32       `json:"free_gpu_count" redis:"gpu_count"`
	Gpu                  string       `json:"gpu" redis:"gpu"`
	PoolName             string       `json:"pool_name" redis:"pool_name"`
	MachineId            string       `json:"machine_id" redis:"machine_id"`
	ResourceVersion      int64        `json:"resource_version" redis:"resource_version"`
	RequiresPoolSelector bool         `json:"requires_pool_selector" redis:"requires_pool_selector"`
}

type WorkerConfig

type WorkerConfig struct {
	Pools                      map[string]WorkerPoolConfig `key:"pools" json:"pools"`
	HostNetwork                bool                        `key:"hostNetwork" json:"host_network"`
	ImageTag                   string                      `key:"imageTag" json:"image_tag"`
	ImageName                  string                      `key:"imageName" json:"image_name"`
	ImageRegistry              string                      `key:"imageRegistry" json:"image_registry"`
	ImagePullSecrets           []string                    `key:"imagePullSecrets" json:"image_pull_secrets"`
	Namespace                  string                      `key:"namespace" json:"namespace"`
	ServiceAccountName         string                      `key:"serviceAccountName" json:"service_account_name"`
	ResourcesEnforced          bool                        `key:"resourcesEnforced" json:"resources_enforced"`
	DefaultWorkerCPURequest    int64                       `key:"defaultWorkerCPURequest" json:"default_worker_cpu_request"`
	DefaultWorkerMemoryRequest int64                       `key:"defaultWorkerMemoryRequest" json:"default_worker_memory_request"`
	ImagePVCName               string                      `key:"imagePVCName" json:"image_pvc_name"`
	AddWorkerTimeout           time.Duration               `key:"addWorkerTimeout" json:"add_worker_timeout"`
	TerminationGracePeriod     int64                       `key:"terminationGracePeriod"`
}

type WorkerPoolConfig

type WorkerPoolConfig struct {
	GPUType              string                            `key:"gpuType" json:"gpu_type"`
	Runtime              string                            `key:"runtime" json:"runtime"`
	Mode                 PoolMode                          `key:"mode" json:"mode"`
	Provider             *MachineProvider                  `key:"provider" json:"provider"`
	JobSpec              WorkerPoolJobSpecConfig           `key:"jobSpec" json:"job_spec"`
	PoolSizing           WorkerPoolJobSpecPoolSizingConfig `key:"poolSizing" json:"pool_sizing"`
	RequiresPoolSelector bool                              `key:"requiresPoolSelector" json:"requires_pool_selector"`
}

type WorkerPoolJobSpecConfig

type WorkerPoolJobSpecConfig struct {
	NodeSelector map[string]string `key:"nodeSelector" json:"node_selector"`
	Env          []corev1.EnvVar   `key:"env" json:"env"`

	// Mimics corev1.Volume since that type doesn't currently serialize correctly
	Volumes []struct {
		Name   string `key:"name" json:"name"`
		Secret struct {
			SecretName string `key:"secretName" json:"secret_name"`
		} `key:"secret" json:"secret"`
	} `key:"volumes" json:"volumes"`

	VolumeMounts []corev1.VolumeMount `key:"volumeMounts" json:"volume_mounts"`
}

type WorkerPoolJobSpecPoolSizingConfig

type WorkerPoolJobSpecPoolSizingConfig struct {
	DefaultWorkerCPU      string `key:"defaultWorkerCPU" json:"default_worker_cpu"`
	DefaultWorkerMemory   string `key:"defaultWorkerMemory" json:"default_worker_memory"`
	DefaultWorkerGpuType  string `key:"defaultWorkerGPUType" json:"default_worker_gpu_type"`
	DefaultWorkerGpuCount string `key:"defaultWorkerGpuCount" json:"default_worker_gpu_count"`
	MinFreeCPU            string `key:"minFreeCPU" json:"min_free_cpu"`
	MinFreeMemory         string `key:"minFreeMemory" json:"min_free_memory"`
	MinFreeGPU            string `key:"minFreeGPU" json:"min_free_gpu"`
}

type WorkerPoolSizingConfig

type WorkerPoolSizingConfig struct {
	MinFreeCpu            int64
	MinFreeMemory         int64
	MinFreeGpu            uint
	DefaultWorkerCpu      int64
	DefaultWorkerMemory   int64
	DefaultWorkerGpuType  string
	DefaultWorkerGpuCount uint32
}

func NewWorkerPoolSizingConfig

func NewWorkerPoolSizingConfig() *WorkerPoolSizingConfig

type WorkerStatus

type WorkerStatus string

type Workspace

type Workspace struct {
	Id                 uint              `db:"id" json:"id,omitempty"`
	ExternalId         string            `db:"external_id" json:"external_id"`
	Name               string            `db:"name" json:"name"`
	CreatedAt          time.Time         `db:"created_at" json:"created_at,omitempty"`
	UpdatedAt          time.Time         `db:"updated_at" json:"updated_at,omitempty"`
	SigningKey         *string           `db:"signing_key" json:"signing_key"`
	ConcurrencyLimitId *uint             `db:"concurrency_limit_id" json:"concurrency_limit_id,omitempty"`
	ConcurrencyLimit   *ConcurrencyLimit `db:"concurrency_limit" json:"concurrency_limit"`
}

Jump to

Keyboard shortcuts

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