repository

package
v0.0.0-...-299106d Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScheduledJobsChannel = "jobs"
)

Variables

View Source
var PostgresDataError = pq.ErrorClass("22")

Functions

func GenerateDSN

func GenerateDSN(config types.PostgresConfig) string

func NewRedisClientForTest

func NewRedisClientForTest() (*common.RedisClient, error)

Types

type AuthInfo

type AuthInfo struct {
	Workspace *types.Workspace
	Token     *types.Token
}

type BackendRepository

type BackendRepository interface {
	ListWorkspaces(ctx context.Context) ([]types.Workspace, error)
	CreateWorkspace(ctx context.Context) (types.Workspace, error)
	GetWorkspaceByExternalId(ctx context.Context, externalId string) (types.Workspace, error)
	GetWorkspaceByExternalIdWithSigningKey(ctx context.Context, externalId string) (types.Workspace, error)
	GetWorkspace(ctx context.Context, workspaceId uint) (*types.Workspace, error)
	GetWorkspaceStorage(ctx context.Context, storageId uint) (*types.WorkspaceStorage, error)
	CreateWorkspaceStorage(ctx context.Context, workspaceId uint, storage types.WorkspaceStorage) (*types.WorkspaceStorage, error)
	GetAdminWorkspace(ctx context.Context) (*types.Workspace, error)
	CreateObject(ctx context.Context, hash string, size int64, workspaceId uint) (*types.Object, error)
	GetObjectByHash(ctx context.Context, hash string, workspaceId uint) (*types.Object, error)
	GetObjectByExternalId(ctx context.Context, externalId string, workspaceId uint) (types.Object, error)
	GetObjectByExternalStubId(ctx context.Context, stubId string, workspaceId uint) (types.Object, error)
	UpdateObjectSizeByExternalId(ctx context.Context, externalId string, size int) error
	DeleteObjectByExternalId(ctx context.Context, externalId string) error
	CreateToken(ctx context.Context, workspaceId uint, tokenType string, reusable bool) (types.Token, error)
	AuthorizeToken(ctx context.Context, tokenKey string) (*types.Token, *types.Workspace, error)
	RetrieveActiveToken(ctx context.Context, workspaceId uint) (*types.Token, error)
	GetTokenByExternalId(ctx context.Context, workspaceId uint, extTokenId string) (*types.Token, error)
	ListTokens(ctx context.Context, workspaceId uint) ([]types.Token, error)
	UpdateTokenAsClusterAdmin(ctx context.Context, tokenId string, disabled bool) error
	ToggleToken(ctx context.Context, workspaceId uint, extTokenId string) (types.Token, error)
	DeleteToken(ctx context.Context, workspaceId uint, extTokenId string) error
	GetTask(ctx context.Context, externalId string) (*types.Task, error)
	GetTaskStatus(ctx context.Context, externalId string) (types.TaskStatus, error)
	GetTaskWithRelated(ctx context.Context, externalId string) (*types.TaskWithRelated, error)
	GetTaskByWorkspace(ctx context.Context, externalId string, workspace *types.Workspace) (*types.TaskWithRelated, error)
	CreateTask(ctx context.Context, params *types.TaskParams) (*types.Task, error)
	UpdateTask(ctx context.Context, externalId string, updatedTask types.Task) (*types.Task, error)
	DeleteTask(ctx context.Context, externalId string) error
	ListTasks(ctx context.Context) ([]types.Task, error)
	ListTasksWithRelated(ctx context.Context, filters types.TaskFilter) ([]types.TaskWithRelated, error)
	ListTasksWithRelatedPaginated(ctx context.Context, filters types.TaskFilter) (common.CursorPaginationInfo[types.TaskWithRelated], error)
	AggregateTasksByTimeWindow(ctx context.Context, filters types.TaskFilter) ([]types.TaskCountByTime, error)
	GetTaskCountPerDeployment(ctx context.Context, filters types.TaskFilter) ([]types.TaskCountPerDeployment, error)
	GetOrCreateStub(ctx context.Context, name, stubType string, config types.StubConfigV1, objectId, workspaceId uint, forceCreate bool, appId uint) (types.Stub, error)
	UpdateStubConfig(ctx context.Context, stubId uint, config *types.StubConfigV1) error
	GetStubByExternalId(ctx context.Context, externalId string, queryFilters ...types.QueryFilter) (*types.StubWithRelated, error)
	GetStubById(ctx context.Context, stubId uint, queryFilters ...types.QueryFilter) (*types.StubWithRelated, error)
	GetDeploymentBySubdomain(ctx context.Context, subdomain string, version uint) (*types.DeploymentWithRelated, error)
	GetVolume(ctx context.Context, workspaceId uint, name string) (*types.Volume, error)
	GetVolumeByExternalId(ctx context.Context, workspaceId uint, externalId string) (*types.Volume, error)
	GetOrCreateVolume(ctx context.Context, workspaceId uint, name string) (*types.Volume, error)
	DeleteVolume(ctx context.Context, workspaceId uint, name string) error
	ListVolumesWithRelated(ctx context.Context, workspaceId uint) ([]types.VolumeWithRelated, error)
	ListDeploymentsWithRelated(ctx context.Context, filters types.DeploymentFilter) ([]types.DeploymentWithRelated, error)
	ListLatestDeploymentsWithRelatedPaginated(ctx context.Context, filters types.DeploymentFilter) (common.CursorPaginationInfo[types.DeploymentWithRelated], error)
	ListDeploymentsPaginated(ctx context.Context, filters types.DeploymentFilter) (common.CursorPaginationInfo[types.DeploymentWithRelated], error)
	GetLatestDeploymentByName(ctx context.Context, workspaceId uint, name string, stubType string, filterDeleted bool) (*types.DeploymentWithRelated, error)
	GetDeploymentByExternalId(ctx context.Context, workspaceId uint, deploymentExternalId string) (*types.DeploymentWithRelated, error)
	GetAnyDeploymentByExternalId(ctx context.Context, deploymentExternalId string) (*types.DeploymentWithRelated, error)
	GetDeploymentByStubExternalId(ctx context.Context, workspaceId uint, stubExternalId string) (*types.DeploymentWithRelated, error)
	GetDeploymentByNameAndVersion(ctx context.Context, workspaceId uint, name string, version uint, stubType string) (*types.DeploymentWithRelated, error)
	CreateDeployment(ctx context.Context, workspaceId uint, name string, version uint, stubId uint, stubType string, appId uint) (*types.Deployment, error)
	UpdateDeployment(ctx context.Context, deployment types.Deployment) (*types.Deployment, error)
	DeleteDeployment(ctx context.Context, deployment types.Deployment) error
	ListStubs(ctx context.Context, filters types.StubFilter) ([]types.StubWithRelated, error)
	ListStubsPaginated(ctx context.Context, filters types.StubFilter) (common.CursorPaginationInfo[types.StubWithRelated], error)
	GetConcurrencyLimit(ctx context.Context, concurrenyLimitId uint) (*types.ConcurrencyLimit, error)
	GetConcurrencyLimitByWorkspaceId(ctx context.Context, workspaceId string) (*types.ConcurrencyLimit, error)
	DeleteConcurrencyLimit(ctx context.Context, workspaceId types.Workspace) error
	CreateConcurrencyLimit(ctx context.Context, workspaceId uint, gpuLimit uint32, cpuMillicoreLimit uint32) (*types.ConcurrencyLimit, error)
	UpdateConcurrencyLimit(ctx context.Context, concurrencyLimitId uint, gpuLimit uint32, cpuMillicoreLimit uint32) (*types.ConcurrencyLimit, error)
	ListConcurrencyLimitsByWorkspaceId(ctx context.Context, workspaceId string) ([]types.ConcurrencyLimit, error)
	RevertToConcurrencyLimit(ctx context.Context, workspaceId string, concurrencyLimitId string) (*types.ConcurrencyLimit, error)
	CreateSecret(ctx context.Context, workspace *types.Workspace, tokenId uint, name string, value string, validateName bool) (*types.Secret, error)
	GetSecretByName(ctx context.Context, workspace *types.Workspace, name string) (*types.Secret, error)
	GetSecretsByName(ctx context.Context, workspace *types.Workspace, names []string) ([]types.Secret, error)
	GetSecretByNameDecrypted(ctx context.Context, workspace *types.Workspace, name string) (*types.Secret, error)
	GetSecretsByNameDecrypted(ctx context.Context, workspace *types.Workspace, names []string) ([]types.Secret, error)
	ListSecrets(ctx context.Context, workspace *types.Workspace) ([]types.Secret, error)
	UpdateSecret(ctx context.Context, workspace *types.Workspace, tokenId uint, secretName string, value string) (*types.Secret, error)
	DeleteSecret(ctx context.Context, workspace *types.Workspace, secretName string) error
	CreateScheduledJob(ctx context.Context, scheduledJob *types.ScheduledJob) (*types.ScheduledJob, error)
	DeleteScheduledJob(ctx context.Context, scheduledJob *types.ScheduledJob) error
	DeletePreviousScheduledJob(ctx context.Context, deployment *types.Deployment) error
	GetScheduledJob(ctx context.Context, deploymentId uint) (*types.ScheduledJob, error)
	ListenToChannel(ctx context.Context, channel string) (<-chan string, error)
	Ping() error
	GetTaskMetrics(ctx context.Context, periodStart time.Time, periodEnd time.Time) (types.TaskMetrics, error)
	GetOrCreateApp(ctx context.Context, workspaceId uint, appName string) (*types.App, error)
	RetrieveApp(ctx context.Context, workspaceId uint, appId string) (*types.App, error)
	RetrieveAppByStubExternalId(ctx context.Context, stubExternalId string) (*types.App, error)
	ListApps(ctx context.Context, workspaceId uint) ([]types.App, error)
	ListAppsPaginated(ctx context.Context, workspaceId uint, filters types.AppFilter) (common.CursorPaginationInfo[types.App], error)
	DeleteApp(ctx context.Context, appId string) error
	GetImageClipVersion(ctx context.Context, imageId string) (uint32, error)
	CreateImage(ctx context.Context, imageId string, clipVersion uint32) (uint32, error)
	SetImageCredentialSecret(ctx context.Context, imageId string, secretName string, secretExternalId string) error
	GetImageCredentialSecret(ctx context.Context, imageId string) (string, string, error)
	CreateCheckpoint(ctx context.Context, checkpoint *types.Checkpoint) (*types.Checkpoint, error)
	UpdateCheckpoint(ctx context.Context, checkpoint *types.Checkpoint) (*types.Checkpoint, error)
	ListCheckpoints(ctx context.Context, workspaceExternalId string) ([]types.Checkpoint, error)
	GetCheckpointById(ctx context.Context, checkpointId string) (*types.Checkpoint, error)
	GetLatestCheckpointByStubId(ctx context.Context, stubExternalId string) (*types.Checkpoint, error)
}

func NewBackendPostgresRepositoryForTest

func NewBackendPostgresRepositoryForTest() (BackendRepository, sqlmock.Sqlmock)

type ContainerRedisRepository

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

func (*ContainerRedisRepository) DeleteContainerState

func (cr *ContainerRedisRepository) DeleteContainerState(containerId string) error

func (*ContainerRedisRepository) DeleteStubState

func (cr *ContainerRedisRepository) DeleteStubState(stubId string) error

func (*ContainerRedisRepository) GetActiveContainersByStubId

func (cr *ContainerRedisRepository) GetActiveContainersByStubId(stubId string) ([]types.ContainerState, error)

func (*ContainerRedisRepository) GetActiveContainersByWorkerId

func (cr *ContainerRedisRepository) GetActiveContainersByWorkerId(workerId string) ([]types.ContainerState, error)

func (*ContainerRedisRepository) GetActiveContainersByWorkspaceId

func (cr *ContainerRedisRepository) GetActiveContainersByWorkspaceId(workspaceId string) ([]types.ContainerState, error)

func (*ContainerRedisRepository) GetContainerAddress

func (cr *ContainerRedisRepository) GetContainerAddress(containerId string) (string, error)

func (*ContainerRedisRepository) GetContainerAddressMap

func (cr *ContainerRedisRepository) GetContainerAddressMap(containerId string) (map[int32]string, error)

func (*ContainerRedisRepository) GetContainerExitCode

func (cr *ContainerRedisRepository) GetContainerExitCode(containerId string) (int, error)

func (*ContainerRedisRepository) GetContainerRequestStatus

func (cr *ContainerRedisRepository) GetContainerRequestStatus(containerId string) (types.ContainerRequestStatus, error)

func (*ContainerRedisRepository) GetContainerState

func (cr *ContainerRedisRepository) GetContainerState(containerId string) (*types.ContainerState, error)

func (*ContainerRedisRepository) GetFailedContainersByStubId

func (cr *ContainerRedisRepository) GetFailedContainersByStubId(stubId string) ([]string, error)

func (*ContainerRedisRepository) GetStubState

func (cr *ContainerRedisRepository) GetStubState(stubId string) (string, error)

func (*ContainerRedisRepository) GetWorkerAddress

func (cr *ContainerRedisRepository) GetWorkerAddress(ctx context.Context, containerId string) (string, error)

func (*ContainerRedisRepository) HasBuildContainerTTL

func (cr *ContainerRedisRepository) HasBuildContainerTTL(containerId string) bool

func (*ContainerRedisRepository) SetBuildContainerTTL

func (cr *ContainerRedisRepository) SetBuildContainerTTL(containerId string, ttl time.Duration) error

func (*ContainerRedisRepository) SetContainerAddress

func (cr *ContainerRedisRepository) SetContainerAddress(containerId string, addr string) error

func (*ContainerRedisRepository) SetContainerAddressMap

func (cr *ContainerRedisRepository) SetContainerAddressMap(containerId string, addressMap map[int32]string) error

func (*ContainerRedisRepository) SetContainerExitCode

func (cr *ContainerRedisRepository) SetContainerExitCode(containerId string, exitCode int) error

func (*ContainerRedisRepository) SetContainerRequestStatus

func (cr *ContainerRedisRepository) SetContainerRequestStatus(containerId string, status types.ContainerRequestStatus) error

func (*ContainerRedisRepository) SetContainerState

func (cr *ContainerRedisRepository) SetContainerState(containerId string, state *types.ContainerState) error

func (*ContainerRedisRepository) SetContainerStateWithConcurrencyLimit

func (c *ContainerRedisRepository) SetContainerStateWithConcurrencyLimit(quota *types.ConcurrencyLimit, request *types.ContainerRequest) error

func (*ContainerRedisRepository) SetStubState

func (cr *ContainerRedisRepository) SetStubState(stubId, state string) error

func (*ContainerRedisRepository) SetWorkerAddress

func (cr *ContainerRedisRepository) SetWorkerAddress(containerId string, addr string) error

func (*ContainerRedisRepository) UpdateAssignedContainerGPU

func (cr *ContainerRedisRepository) UpdateAssignedContainerGPU(containerId string, gpuType string) error

func (*ContainerRedisRepository) UpdateContainerStatus

func (cr *ContainerRedisRepository) UpdateContainerStatus(containerId string, status types.ContainerStatus, expirySeconds int64) error

type ContainerRepository

type ContainerRepository interface {
	GetContainerState(string) (*types.ContainerState, error)
	SetContainerState(string, *types.ContainerState) error
	SetContainerExitCode(string, int) error
	GetContainerExitCode(string) (int, error)
	SetContainerAddress(containerId string, addr string) error
	GetContainerAddress(containerId string) (string, error)
	UpdateContainerStatus(string, types.ContainerStatus, int64) error
	UpdateAssignedContainerGPU(string, string) error
	DeleteContainerState(containerId string) error
	SetContainerRequestStatus(containerId string, status types.ContainerRequestStatus) error
	SetWorkerAddress(containerId string, addr string) error
	GetWorkerAddress(ctx context.Context, containerId string) (string, error)
	SetContainerAddressMap(containerId string, addressMap map[int32]string) error
	GetContainerAddressMap(containerId string) (map[int32]string, error)
	SetContainerStateWithConcurrencyLimit(quota *types.ConcurrencyLimit, request *types.ContainerRequest) error
	GetActiveContainersByStubId(stubId string) ([]types.ContainerState, error)
	GetActiveContainersByWorkspaceId(workspaceId string) ([]types.ContainerState, error)
	GetActiveContainersByWorkerId(workerId string) ([]types.ContainerState, error)
	GetFailedContainersByStubId(stubId string) ([]string, error)
	GetStubState(stubId string) (string, error)
	SetStubState(stubId, state string) error
	DeleteStubState(stubId string) error
	SetBuildContainerTTL(containerId string, ttl time.Duration) error
	HasBuildContainerTTL(containerId string) bool
}

func NewContainerRedisRepository

func NewContainerRedisRepository(r *common.RedisClient) ContainerRepository

func NewContainerRedisRepositoryForTest

func NewContainerRedisRepositoryForTest(rdb *common.RedisClient) ContainerRepository

type EventRepository

type EventRepository interface {
	PushContainerRequestedEvent(request *types.ContainerRequest)
	PushContainerScheduledEvent(containerID string, workerID string, request *types.ContainerRequest)
	PushContainerStartedEvent(containerID string, workerID string, request *types.ContainerRequest)
	PushContainerStoppedEvent(containerID string, workerID string, request *types.ContainerRequest, exitCode int)
	PushContainerOOMEvent(containerID string, workerID string, request *types.ContainerRequest)
	PushContainerResourceMetricsEvent(workerID string, request *types.ContainerRequest, metrics types.EventContainerMetricsData)
	PushWorkerStartedEvent(workerID string)
	PushWorkerStoppedEvent(workerID string)
	PushWorkerDeletedEvent(workerID, machineID, poolName string, reason types.DeletedWorkerReason)
	PushDeployStubEvent(workspaceId string, stub *types.Stub)
	PushServeStubEvent(workspaceId string, stub *types.Stub)
	PushRunStubEvent(workspaceId string, stub *types.Stub)
	PushCloneStubEvent(workspaceId string, stub *types.Stub, parentStub *types.Stub)
	PushTaskUpdatedEvent(task *types.TaskWithRelated)
	PushTaskCreatedEvent(task *types.TaskWithRelated)
	PushStubStateUnhealthy(workspaceId string, stubId string, currentState, previousState string, reason string, failedContainers []string)
	PushWorkerPoolDegradedEvent(poolName string, reasons []string, poolState *types.WorkerPoolState)
	PushWorkerPoolHealthyEvent(poolName string, poolState *types.WorkerPoolState)
	PushGatewayEndpointCalledEvent(method, path, workspaceID string, statusCode int, userAgent, remoteIP, requestID, contentType, accept, errorMessage string)
}

func NewTCPEventClientRepo

func NewTCPEventClientRepo(config types.FluentBitEventConfig) EventRepository

type GooseLogger

type GooseLogger struct {
	zerolog.Logger
}

func (*GooseLogger) Fatalf

func (l *GooseLogger) Fatalf(format string, v ...any)

type PostgresBackendRepository

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

func NewBackendPostgresRepository

func NewBackendPostgresRepository(config types.PostgresConfig, eventRepo EventRepository) (*PostgresBackendRepository, error)

func (*PostgresBackendRepository) AggregateTasksByTimeWindow

func (c *PostgresBackendRepository) AggregateTasksByTimeWindow(ctx context.Context, filters types.TaskFilter) ([]types.TaskCountByTime, error)

func (*PostgresBackendRepository) AuthorizeToken

func (r *PostgresBackendRepository) AuthorizeToken(ctx context.Context, tokenKey string) (*types.Token, *types.Workspace, error)

func (*PostgresBackendRepository) CreateCheckpoint

func (r *PostgresBackendRepository) CreateCheckpoint(ctx context.Context, checkpoint *types.Checkpoint) (*types.Checkpoint, error)

func (*PostgresBackendRepository) CreateConcurrencyLimit

func (r *PostgresBackendRepository) CreateConcurrencyLimit(ctx context.Context, workspaceId uint, gpuLimit uint32, cpuMillicoreLimit uint32) (*types.ConcurrencyLimit, error)

func (*PostgresBackendRepository) CreateDeployment

func (c *PostgresBackendRepository) CreateDeployment(ctx context.Context, workspaceId uint, name string, version uint, stubId uint, stubType string, appId uint) (*types.Deployment, error)

func (*PostgresBackendRepository) CreateImage

func (r *PostgresBackendRepository) CreateImage(ctx context.Context, imageId string, clipVersion uint32) (uint32, error)

func (*PostgresBackendRepository) CreateObject

func (r *PostgresBackendRepository) CreateObject(ctx context.Context, hash string, size int64, workspaceId uint) (*types.Object, error)

func (*PostgresBackendRepository) CreateScheduledJob

func (r *PostgresBackendRepository) CreateScheduledJob(ctx context.Context, scheduledJob *types.ScheduledJob) (*types.ScheduledJob, error)

func (*PostgresBackendRepository) CreateSecret

func (r *PostgresBackendRepository) CreateSecret(ctx context.Context, workspace *types.Workspace, tokenId uint, name string, value string, validateName bool) (*types.Secret, error)

func (*PostgresBackendRepository) CreateTask

func (r *PostgresBackendRepository) CreateTask(ctx context.Context, params *types.TaskParams) (*types.Task, error)

func (*PostgresBackendRepository) CreateToken

func (r *PostgresBackendRepository) CreateToken(ctx context.Context, workspaceId uint, tokenType string, reusable bool) (types.Token, error)

func (*PostgresBackendRepository) CreateWorkspace

func (r *PostgresBackendRepository) CreateWorkspace(ctx context.Context) (types.Workspace, error)

func (*PostgresBackendRepository) CreateWorkspaceStorage

func (r *PostgresBackendRepository) CreateWorkspaceStorage(ctx context.Context, workspaceId uint, storage types.WorkspaceStorage) (*types.WorkspaceStorage, error)

func (*PostgresBackendRepository) DeleteApp

func (r *PostgresBackendRepository) DeleteApp(ctx context.Context, appId string) error

func (*PostgresBackendRepository) DeleteConcurrencyLimit

func (r *PostgresBackendRepository) DeleteConcurrencyLimit(ctx context.Context, workspaceId types.Workspace) error

func (*PostgresBackendRepository) DeleteDeployment

func (r *PostgresBackendRepository) DeleteDeployment(ctx context.Context, deployment types.Deployment) error

func (*PostgresBackendRepository) DeleteObjectByExternalId

func (r *PostgresBackendRepository) DeleteObjectByExternalId(ctx context.Context, externalId string) error

func (*PostgresBackendRepository) DeletePreviousScheduledJob

func (r *PostgresBackendRepository) DeletePreviousScheduledJob(ctx context.Context, deployment *types.Deployment) error

func (*PostgresBackendRepository) DeleteScheduledJob

func (r *PostgresBackendRepository) DeleteScheduledJob(ctx context.Context, scheduledJob *types.ScheduledJob) error

func (*PostgresBackendRepository) DeleteSecret

func (r *PostgresBackendRepository) DeleteSecret(ctx context.Context, workspace *types.Workspace, name string) error

func (*PostgresBackendRepository) DeleteTask

func (r *PostgresBackendRepository) DeleteTask(ctx context.Context, externalId string) error

func (*PostgresBackendRepository) DeleteToken

func (r *PostgresBackendRepository) DeleteToken(ctx context.Context, workspaceId uint, extTokenId string) error

func (*PostgresBackendRepository) DeleteVolume

func (c *PostgresBackendRepository) DeleteVolume(ctx context.Context, workspaceId uint, name string) error

func (*PostgresBackendRepository) GetAdminWorkspace

func (r *PostgresBackendRepository) GetAdminWorkspace(ctx context.Context) (*types.Workspace, error)

func (*PostgresBackendRepository) GetAnyDeploymentByExternalId

func (c *PostgresBackendRepository) GetAnyDeploymentByExternalId(ctx context.Context, deploymentExternalId string) (*types.DeploymentWithRelated, error)

func (*PostgresBackendRepository) GetCheckpointById

func (r *PostgresBackendRepository) GetCheckpointById(ctx context.Context, checkpointId string) (*types.Checkpoint, error)

func (*PostgresBackendRepository) GetConcurrencyLimit

func (r *PostgresBackendRepository) GetConcurrencyLimit(ctx context.Context, concurrencyLimitId uint) (*types.ConcurrencyLimit, error)

func (*PostgresBackendRepository) GetConcurrencyLimitByWorkspaceId

func (r *PostgresBackendRepository) GetConcurrencyLimitByWorkspaceId(ctx context.Context, workspaceId string) (*types.ConcurrencyLimit, error)

func (*PostgresBackendRepository) GetDeploymentByExternalId

func (c *PostgresBackendRepository) GetDeploymentByExternalId(ctx context.Context, workspaceId uint, deploymentExternalId string) (*types.DeploymentWithRelated, error)

func (*PostgresBackendRepository) GetDeploymentByNameAndVersion

func (c *PostgresBackendRepository) GetDeploymentByNameAndVersion(ctx context.Context, workspaceId uint, name string, version uint, stubType string) (*types.DeploymentWithRelated, error)

func (*PostgresBackendRepository) GetDeploymentByStubExternalId

func (c *PostgresBackendRepository) GetDeploymentByStubExternalId(ctx context.Context, workspaceId uint, stubExternalId string) (*types.DeploymentWithRelated, error)

func (*PostgresBackendRepository) GetDeploymentBySubdomain

func (c *PostgresBackendRepository) GetDeploymentBySubdomain(ctx context.Context, subdomain string, version uint) (*types.DeploymentWithRelated, error)

GetDeploymentBySubdomain retrieves the deployment by name, version, and stub group If version is 0, it will return the latest version

func (*PostgresBackendRepository) GetImageClipVersion

func (r *PostgresBackendRepository) GetImageClipVersion(ctx context.Context, imageId string) (uint32, error)

func (*PostgresBackendRepository) GetImageCredentialSecret

func (r *PostgresBackendRepository) GetImageCredentialSecret(ctx context.Context, imageId string) (string, string, error)

func (*PostgresBackendRepository) GetLatestCheckpointByStubId

func (r *PostgresBackendRepository) GetLatestCheckpointByStubId(ctx context.Context, stubExternalId string) (*types.Checkpoint, error)

func (*PostgresBackendRepository) GetLatestDeploymentByName

func (c *PostgresBackendRepository) GetLatestDeploymentByName(ctx context.Context, workspaceId uint, name string, stubType string, filterDeleted bool) (*types.DeploymentWithRelated, error)

func (*PostgresBackendRepository) GetObjectByExternalId

func (r *PostgresBackendRepository) GetObjectByExternalId(ctx context.Context, externalId string, workspaceId uint) (types.Object, error)

func (*PostgresBackendRepository) GetObjectByExternalStubId

func (r *PostgresBackendRepository) GetObjectByExternalStubId(ctx context.Context, stubId string, workspaceId uint) (types.Object, error)

func (*PostgresBackendRepository) GetObjectByHash

func (r *PostgresBackendRepository) GetObjectByHash(ctx context.Context, hash string, workspaceId uint) (*types.Object, error)

func (*PostgresBackendRepository) GetOrCreateApp

func (r *PostgresBackendRepository) GetOrCreateApp(ctx context.Context, workspaceId uint, appName string) (*types.App, error)

func (*PostgresBackendRepository) GetOrCreateStub

func (r *PostgresBackendRepository) GetOrCreateStub(ctx context.Context, name, stubType string, config types.StubConfigV1, objectId, workspaceId uint, forceCreate bool, appId uint) (types.Stub, error)

func (*PostgresBackendRepository) GetOrCreateVolume

func (c *PostgresBackendRepository) GetOrCreateVolume(ctx context.Context, workspaceId uint, name string) (*types.Volume, error)

func (*PostgresBackendRepository) GetScheduledJob

func (r *PostgresBackendRepository) GetScheduledJob(ctx context.Context, deploymentId uint) (*types.ScheduledJob, error)

func (*PostgresBackendRepository) GetSecretByName

func (r *PostgresBackendRepository) GetSecretByName(ctx context.Context, workspace *types.Workspace, name string) (*types.Secret, error)

func (*PostgresBackendRepository) GetSecretByNameDecrypted

func (r *PostgresBackendRepository) GetSecretByNameDecrypted(ctx context.Context, workspace *types.Workspace, name string) (*types.Secret, error)

func (*PostgresBackendRepository) GetSecretsByName

func (r *PostgresBackendRepository) GetSecretsByName(ctx context.Context, workspace *types.Workspace, names []string) ([]types.Secret, error)

func (*PostgresBackendRepository) GetSecretsByNameDecrypted

func (r *PostgresBackendRepository) GetSecretsByNameDecrypted(ctx context.Context, workspace *types.Workspace, names []string) ([]types.Secret, error)

func (*PostgresBackendRepository) GetStubByExternalId

func (r *PostgresBackendRepository) GetStubByExternalId(ctx context.Context, externalId string, queryFilters ...types.QueryFilter) (*types.StubWithRelated, error)

func (*PostgresBackendRepository) GetStubById

func (r *PostgresBackendRepository) GetStubById(ctx context.Context, stubId uint, queryFilters ...types.QueryFilter) (*types.StubWithRelated, error)

func (*PostgresBackendRepository) GetTask

func (r *PostgresBackendRepository) GetTask(ctx context.Context, externalId string) (*types.Task, error)

func (*PostgresBackendRepository) GetTaskByWorkspace

func (r *PostgresBackendRepository) GetTaskByWorkspace(ctx context.Context, externalId string, workspace *types.Workspace) (*types.TaskWithRelated, error)

func (*PostgresBackendRepository) GetTaskCountPerDeployment

func (c *PostgresBackendRepository) GetTaskCountPerDeployment(ctx context.Context, filters types.TaskFilter) ([]types.TaskCountPerDeployment, error)

func (*PostgresBackendRepository) GetTaskMetrics

func (r *PostgresBackendRepository) GetTaskMetrics(ctx context.Context, periodStart, periodEnd time.Time) (types.TaskMetrics, error)

func (*PostgresBackendRepository) GetTaskStatus

func (r *PostgresBackendRepository) GetTaskStatus(ctx context.Context, externalId string) (types.TaskStatus, error)

func (*PostgresBackendRepository) GetTaskWithRelated

func (r *PostgresBackendRepository) GetTaskWithRelated(ctx context.Context, externalId string) (*types.TaskWithRelated, error)

func (*PostgresBackendRepository) GetTokenByExternalId

func (r *PostgresBackendRepository) GetTokenByExternalId(ctx context.Context, workspaceId uint, extTokenId string) (*types.Token, error)

func (*PostgresBackendRepository) GetVolume

func (c *PostgresBackendRepository) GetVolume(ctx context.Context, workspaceId uint, name string) (*types.Volume, error)

Volume

func (*PostgresBackendRepository) GetVolumeByExternalId

func (c *PostgresBackendRepository) GetVolumeByExternalId(ctx context.Context, workspaceId uint, externalId string) (*types.Volume, error)

func (*PostgresBackendRepository) GetWorkspace

func (r *PostgresBackendRepository) GetWorkspace(ctx context.Context, workspaceId uint) (*types.Workspace, error)

func (*PostgresBackendRepository) GetWorkspaceByExternalId

func (r *PostgresBackendRepository) GetWorkspaceByExternalId(ctx context.Context, externalId string) (types.Workspace, error)

func (*PostgresBackendRepository) GetWorkspaceByExternalIdWithSigningKey

func (r *PostgresBackendRepository) GetWorkspaceByExternalIdWithSigningKey(ctx context.Context, externalId string) (types.Workspace, error)

func (*PostgresBackendRepository) GetWorkspaceStorage

func (r *PostgresBackendRepository) GetWorkspaceStorage(ctx context.Context, storageId uint) (*types.WorkspaceStorage, error)

func (*PostgresBackendRepository) ListApps

func (r *PostgresBackendRepository) ListApps(ctx context.Context, workspaceId uint) ([]types.App, error)

func (*PostgresBackendRepository) ListAppsPaginated

func (r *PostgresBackendRepository) ListAppsPaginated(ctx context.Context, workspaceId uint, filters types.AppFilter) (common.CursorPaginationInfo[types.App], error)

func (*PostgresBackendRepository) ListCheckpoints

func (r *PostgresBackendRepository) ListCheckpoints(ctx context.Context, workspaceExternalId string) ([]types.Checkpoint, error)

func (*PostgresBackendRepository) ListConcurrencyLimitsByWorkspaceId

func (r *PostgresBackendRepository) ListConcurrencyLimitsByWorkspaceId(ctx context.Context, workspaceId string) ([]types.ConcurrencyLimit, error)

func (*PostgresBackendRepository) ListDeploymentsPaginated

func (*PostgresBackendRepository) ListDeploymentsWithRelated

func (c *PostgresBackendRepository) ListDeploymentsWithRelated(ctx context.Context, filters types.DeploymentFilter) ([]types.DeploymentWithRelated, error)

func (*PostgresBackendRepository) ListLatestDeploymentsWithRelatedPaginated

func (c *PostgresBackendRepository) ListLatestDeploymentsWithRelatedPaginated(ctx context.Context, filters types.DeploymentFilter) (common.CursorPaginationInfo[types.DeploymentWithRelated], error)

func (*PostgresBackendRepository) ListSecrets

func (r *PostgresBackendRepository) ListSecrets(ctx context.Context, workspace *types.Workspace) ([]types.Secret, error)

func (*PostgresBackendRepository) ListStubs

func (*PostgresBackendRepository) ListStubsPaginated

func (*PostgresBackendRepository) ListTasks

func (r *PostgresBackendRepository) ListTasks(ctx context.Context) ([]types.Task, error)

func (*PostgresBackendRepository) ListTasksWithRelated

func (c *PostgresBackendRepository) ListTasksWithRelated(ctx context.Context, filters types.TaskFilter) ([]types.TaskWithRelated, error)

func (*PostgresBackendRepository) ListTasksWithRelatedPaginated

func (*PostgresBackendRepository) ListTokens

func (r *PostgresBackendRepository) ListTokens(ctx context.Context, workspaceId uint) ([]types.Token, error)

func (*PostgresBackendRepository) ListVolumesWithRelated

func (c *PostgresBackendRepository) ListVolumesWithRelated(ctx context.Context, workspaceId uint) ([]types.VolumeWithRelated, error)

func (*PostgresBackendRepository) ListWorkspaces

func (r *PostgresBackendRepository) ListWorkspaces(ctx context.Context) ([]types.Workspace, error)

func (*PostgresBackendRepository) ListenToChannel

func (r *PostgresBackendRepository) ListenToChannel(ctx context.Context, channel string) (<-chan string, error)

func (*PostgresBackendRepository) Migrate

func (r *PostgresBackendRepository) Migrate() error

func (*PostgresBackendRepository) Ping

func (r *PostgresBackendRepository) Ping() error

func (*PostgresBackendRepository) RetrieveActiveToken

func (r *PostgresBackendRepository) RetrieveActiveToken(ctx context.Context, workspaceId uint) (*types.Token, error)

func (*PostgresBackendRepository) RetrieveApp

func (r *PostgresBackendRepository) RetrieveApp(ctx context.Context, workspaceId uint, appId string) (*types.App, error)

func (*PostgresBackendRepository) RetrieveAppByStubExternalId

func (r *PostgresBackendRepository) RetrieveAppByStubExternalId(ctx context.Context, stubExternalId string) (*types.App, error)

func (*PostgresBackendRepository) RevertToConcurrencyLimit

func (r *PostgresBackendRepository) RevertToConcurrencyLimit(ctx context.Context, workspaceId string, concurrencyLimitId string) (*types.ConcurrencyLimit, error)

func (*PostgresBackendRepository) RevokeTokenByExternalId

func (r *PostgresBackendRepository) RevokeTokenByExternalId(ctx context.Context, externalId string) error

func (*PostgresBackendRepository) SetImageCredentialSecret

func (r *PostgresBackendRepository) SetImageCredentialSecret(ctx context.Context, imageId string, secretName string, secretExternalId string) error

func (*PostgresBackendRepository) ToggleToken

func (r *PostgresBackendRepository) ToggleToken(ctx context.Context, workspaceId uint, extTokenId string) (types.Token, error)

func (*PostgresBackendRepository) UpdateCheckpoint

func (r *PostgresBackendRepository) UpdateCheckpoint(ctx context.Context, checkpoint *types.Checkpoint) (*types.Checkpoint, error)

func (*PostgresBackendRepository) UpdateConcurrencyLimit

func (r *PostgresBackendRepository) UpdateConcurrencyLimit(ctx context.Context, concurrencyLimitId uint, gpuLimit uint32, cpuMillicoreLimit uint32) (*types.ConcurrencyLimit, error)

func (*PostgresBackendRepository) UpdateDeployment

func (r *PostgresBackendRepository) UpdateDeployment(ctx context.Context, deployment types.Deployment) (*types.Deployment, error)

func (*PostgresBackendRepository) UpdateObjectSizeByExternalId

func (r *PostgresBackendRepository) UpdateObjectSizeByExternalId(ctx context.Context, externalId string, size int) error

func (*PostgresBackendRepository) UpdateSecret

func (r *PostgresBackendRepository) UpdateSecret(ctx context.Context, workspace *types.Workspace, tokenId uint, secretName string, value string) (*types.Secret, error)

func (*PostgresBackendRepository) UpdateStubConfig

func (r *PostgresBackendRepository) UpdateStubConfig(ctx context.Context, stubId uint, config *types.StubConfigV1) error

func (*PostgresBackendRepository) UpdateTask

func (r *PostgresBackendRepository) UpdateTask(ctx context.Context, externalId string, updatedTask types.Task) (*types.Task, error)

func (*PostgresBackendRepository) UpdateTokenAsClusterAdmin

func (r *PostgresBackendRepository) UpdateTokenAsClusterAdmin(ctx context.Context, tokenId string, disabled bool) error

type ProviderRedisRepository

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

func (*ProviderRedisRepository) AddMachine

func (r *ProviderRedisRepository) AddMachine(providerName, poolName, machineId string, machineInfo *types.ProviderMachineState) error

func (*ProviderRedisRepository) GetGPUAvailability

func (r *ProviderRedisRepository) GetGPUAvailability(pools map[string]types.WorkerPoolConfig) (map[string]bool, error)

func (*ProviderRedisRepository) GetGPUCounts

func (r *ProviderRedisRepository) GetGPUCounts(pools map[string]types.WorkerPoolConfig) (map[string]int, error)

func (*ProviderRedisRepository) GetMachine

func (r *ProviderRedisRepository) GetMachine(providerName, poolName, machineId string) (*types.ProviderMachine, error)

func (*ProviderRedisRepository) ListAllMachines

func (r *ProviderRedisRepository) ListAllMachines(providerName, poolName string, useLock bool) ([]*types.ProviderMachine, error)

func (*ProviderRedisRepository) RegisterMachine

func (r *ProviderRedisRepository) RegisterMachine(providerName, poolName, machineId string, newMachineInfo *types.ProviderMachineState, poolConfig *types.WorkerPoolConfig) error

func (*ProviderRedisRepository) RemoveMachine

func (r *ProviderRedisRepository) RemoveMachine(providerName, poolName, machineId string) error

func (*ProviderRedisRepository) RemoveMachineLock

func (r *ProviderRedisRepository) RemoveMachineLock(providerName, poolName, machineId string) error

func (*ProviderRedisRepository) SetLastWorkerSeen

func (r *ProviderRedisRepository) SetLastWorkerSeen(providerName, poolName, machineId string) error

func (*ProviderRedisRepository) SetMachineKeepAlive

func (r *ProviderRedisRepository) SetMachineKeepAlive(providerName, poolName, machineId, agentVersion string, metrics *types.ProviderMachineMetrics) error

func (*ProviderRedisRepository) SetMachineLock

func (r *ProviderRedisRepository) SetMachineLock(providerName, poolName, machineId string) error

func (*ProviderRedisRepository) WaitForMachineRegistration

func (r *ProviderRedisRepository) WaitForMachineRegistration(providerName, poolName, machineId string) (*types.ProviderMachineState, error)

type ProviderRepository

type ProviderRepository interface {
	GetMachine(providerName, poolName, machineId string) (*types.ProviderMachine, error)
	AddMachine(providerName, poolName, machineId string, machineInfo *types.ProviderMachineState) error
	RemoveMachine(providerName, poolName, machineId string) error
	SetMachineKeepAlive(providerName, poolName, machineId, agentVersion string, metrics *types.ProviderMachineMetrics) error
	SetLastWorkerSeen(providerName, poolName, machineId string) error
	RegisterMachine(providerName, poolName, machineId string, newMachineInfo *types.ProviderMachineState, poolConfig *types.WorkerPoolConfig) error
	WaitForMachineRegistration(providerName, poolName, machineId string) (*types.ProviderMachineState, error)
	ListAllMachines(providerName, poolName string, useLock bool) ([]*types.ProviderMachine, error)
	SetMachineLock(providerName, poolName, machineId string) error
	RemoveMachineLock(providerName, poolName, machineId string) error
	GetGPUAvailability(pools map[string]types.WorkerPoolConfig) (map[string]bool, error)
	GetGPUCounts(pools map[string]types.WorkerPoolConfig) (map[string]int, error)
}

func NewProviderRedisRepository

func NewProviderRedisRepository(rdb *common.RedisClient) ProviderRepository

func NewProviderRedisRepositoryForTest

func NewProviderRedisRepositoryForTest(rdb *common.RedisClient) ProviderRepository

type SchedulerRepository

type SchedulerRepository interface{}

type TCPEventClientRepo

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

func (*TCPEventClientRepo) PushCloneStubEvent

func (t *TCPEventClientRepo) PushCloneStubEvent(workspaceId string, stub *types.Stub, parentStub *types.Stub)

func (*TCPEventClientRepo) PushContainerOOMEvent

func (t *TCPEventClientRepo) PushContainerOOMEvent(containerID string, workerID string, request *types.ContainerRequest)

func (*TCPEventClientRepo) PushContainerRequestedEvent

func (t *TCPEventClientRepo) PushContainerRequestedEvent(request *types.ContainerRequest)

func (*TCPEventClientRepo) PushContainerResourceMetricsEvent

func (t *TCPEventClientRepo) PushContainerResourceMetricsEvent(workerID string, request *types.ContainerRequest, metrics types.EventContainerMetricsData)

func (*TCPEventClientRepo) PushContainerScheduledEvent

func (t *TCPEventClientRepo) PushContainerScheduledEvent(containerID string, workerID string, request *types.ContainerRequest)

func (*TCPEventClientRepo) PushContainerStartedEvent

func (t *TCPEventClientRepo) PushContainerStartedEvent(containerID string, workerID string, request *types.ContainerRequest)

func (*TCPEventClientRepo) PushContainerStoppedEvent

func (t *TCPEventClientRepo) PushContainerStoppedEvent(containerID string, workerID string, request *types.ContainerRequest, exitCode int)

func (*TCPEventClientRepo) PushDeployStubEvent

func (t *TCPEventClientRepo) PushDeployStubEvent(workspaceId string, stub *types.Stub)

func (*TCPEventClientRepo) PushGatewayEndpointCalledEvent

func (t *TCPEventClientRepo) PushGatewayEndpointCalledEvent(method, path, workspaceID string, statusCode int, userAgent, remoteIP, requestID, contentType, accept, errorMessage string)

func (*TCPEventClientRepo) PushRunStubEvent

func (t *TCPEventClientRepo) PushRunStubEvent(workspaceId string, stub *types.Stub)

func (*TCPEventClientRepo) PushServeStubEvent

func (t *TCPEventClientRepo) PushServeStubEvent(workspaceId string, stub *types.Stub)

func (*TCPEventClientRepo) PushStubStateUnhealthy

func (t *TCPEventClientRepo) PushStubStateUnhealthy(workspaceId string, stubId string, currentState string, previousState string, reason string, failedContainers []string)

func (*TCPEventClientRepo) PushTaskCreatedEvent

func (t *TCPEventClientRepo) PushTaskCreatedEvent(task *types.TaskWithRelated)

func (*TCPEventClientRepo) PushTaskUpdatedEvent

func (t *TCPEventClientRepo) PushTaskUpdatedEvent(task *types.TaskWithRelated)

func (*TCPEventClientRepo) PushWorkerDeletedEvent

func (t *TCPEventClientRepo) PushWorkerDeletedEvent(workerID, machineID, poolName string, reason types.DeletedWorkerReason)

func (*TCPEventClientRepo) PushWorkerPoolDegradedEvent

func (t *TCPEventClientRepo) PushWorkerPoolDegradedEvent(poolName string, reasons []string, poolState *types.WorkerPoolState)

func (*TCPEventClientRepo) PushWorkerPoolHealthyEvent

func (t *TCPEventClientRepo) PushWorkerPoolHealthyEvent(poolName string, poolState *types.WorkerPoolState)

func (*TCPEventClientRepo) PushWorkerStartedEvent

func (t *TCPEventClientRepo) PushWorkerStartedEvent(workerID string)

func (*TCPEventClientRepo) PushWorkerStoppedEvent

func (t *TCPEventClientRepo) PushWorkerStoppedEvent(workerID string)

type TailscaleRedisRepository

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

func (*TailscaleRedisRepository) GetHostnamesForService

func (ts *TailscaleRedisRepository) GetHostnamesForService(serviceName string) ([]string, error)

func (*TailscaleRedisRepository) SetHostname

func (ts *TailscaleRedisRepository) SetHostname(serviceName, serviceId string, hostName string) error

type TailscaleRepository

type TailscaleRepository interface {
	GetHostnamesForService(serviceName string) ([]string, error)
	SetHostname(serviceName, serviceId, hostName string) error
}

func NewTailscaleRedisRepository

func NewTailscaleRedisRepository(r *common.RedisClient, config types.AppConfig) TailscaleRepository

type TaskRedisRepository

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

func (*TaskRedisRepository) ClaimTask

func (r *TaskRedisRepository) ClaimTask(ctx context.Context, workspaceName, stubId, taskId, containerId string) error

func (*TaskRedisRepository) DeleteTaskState

func (r *TaskRedisRepository) DeleteTaskState(ctx context.Context, workspaceName, stubId, taskId string) error

func (*TaskRedisRepository) GetTaskState

func (r *TaskRedisRepository) GetTaskState(ctx context.Context, workspaceName, stubId, taskId string) (*types.TaskMessage, error)

func (*TaskRedisRepository) GetTasksInFlight

func (r *TaskRedisRepository) GetTasksInFlight(ctx context.Context) ([]*types.TaskMessage, error)

func (*TaskRedisRepository) IsClaimed

func (r *TaskRedisRepository) IsClaimed(ctx context.Context, workspaceName, stubId, taskId string) (bool, error)

func (*TaskRedisRepository) RemoveTaskClaim

func (r *TaskRedisRepository) RemoveTaskClaim(ctx context.Context, workspaceName, stubId, taskId string) error

func (*TaskRedisRepository) RemoveTaskRetryLock

func (r *TaskRedisRepository) RemoveTaskRetryLock(ctx context.Context, workspaceName, stubId, taskId string) error

func (*TaskRedisRepository) SetTaskRetryLock

func (r *TaskRedisRepository) SetTaskRetryLock(ctx context.Context, workspaceName, stubId, taskId string) error

func (*TaskRedisRepository) SetTaskState

func (r *TaskRedisRepository) SetTaskState(ctx context.Context, workspaceName, stubId, taskId string, msg []byte) error

func (*TaskRedisRepository) TasksClaimed

func (r *TaskRedisRepository) TasksClaimed(ctx context.Context, workspaceName, stubId string) (int, error)

func (*TaskRedisRepository) TasksInFlight

func (r *TaskRedisRepository) TasksInFlight(ctx context.Context, workspaceName, stubId string) (int, error)

type TaskRepository

type TaskRepository interface {
	GetTaskState(ctx context.Context, workspaceName, stubId, taskId string) (*types.TaskMessage, error)
	SetTaskState(ctx context.Context, workspaceName, stubId, taskId string, msg []byte) error
	DeleteTaskState(ctx context.Context, workspaceName, stubId, taskId string) error
	GetTasksInFlight(ctx context.Context) ([]*types.TaskMessage, error)
	ClaimTask(ctx context.Context, workspaceName, stubId, taskId, containerId string) error
	RemoveTaskClaim(ctx context.Context, workspaceName, stubId, taskId string) error
	IsClaimed(ctx context.Context, workspaceName, stubId, taskId string) (bool, error)
	TasksClaimed(ctx context.Context, workspaceName, stubId string) (int, error)
	TasksInFlight(ctx context.Context, workspaceName, stubId string) (int, error)
	SetTaskRetryLock(ctx context.Context, workspaceName, stubId, taskId string) error
	RemoveTaskRetryLock(ctx context.Context, workspaceName, stubId, taskId string) error
}

func NewTaskRedisRepository

func NewTaskRedisRepository(r *common.RedisClient) TaskRepository

type UsageMetricsRepository

type UsageMetricsRepository interface {
	Init(source string) error
	IncrementCounter(name string, metadata map[string]interface{}, value float64) error
	SetGauge(name string, metadata map[string]interface{}, value float64) error
}

type WorkerPoolRedisRepository

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

func (*WorkerPoolRedisRepository) GetWorkerPoolState

func (r *WorkerPoolRedisRepository) GetWorkerPoolState(ctx context.Context, poolName string) (*types.WorkerPoolState, error)

GetWorkerPoolState retrieves a collection of health metrics for a worker pool

func (*WorkerPoolRedisRepository) RemoveWorkerCleanerLock

func (r *WorkerPoolRedisRepository) RemoveWorkerCleanerLock(poolName string) error

func (*WorkerPoolRedisRepository) RemoveWorkerPoolSizerLock

func (r *WorkerPoolRedisRepository) RemoveWorkerPoolSizerLock(poolName string) error

func (*WorkerPoolRedisRepository) RemoveWorkerPoolStateLock

func (r *WorkerPoolRedisRepository) RemoveWorkerPoolStateLock(poolName string) error

func (*WorkerPoolRedisRepository) SetWorkerCleanerLock

func (r *WorkerPoolRedisRepository) SetWorkerCleanerLock(poolName string) error

func (*WorkerPoolRedisRepository) SetWorkerPoolSizerLock

func (r *WorkerPoolRedisRepository) SetWorkerPoolSizerLock(poolName string) error

func (*WorkerPoolRedisRepository) SetWorkerPoolState

func (r *WorkerPoolRedisRepository) SetWorkerPoolState(ctx context.Context, poolName string, state *types.WorkerPoolState) error

SetWorkerPoolState updates the worker pool state with some recent health metrics

func (*WorkerPoolRedisRepository) SetWorkerPoolStateLock

func (r *WorkerPoolRedisRepository) SetWorkerPoolStateLock(poolName string) error

type WorkerPoolRepository

type WorkerPoolRepository interface {
	SetWorkerPoolState(ctx context.Context, poolName string, state *types.WorkerPoolState) error
	GetWorkerPoolState(ctx context.Context, poolName string) (*types.WorkerPoolState, error)
	SetWorkerPoolStateLock(poolName string) error
	RemoveWorkerPoolStateLock(poolName string) error
	SetWorkerPoolSizerLock(poolName string) error
	RemoveWorkerPoolSizerLock(poolName string) error
	SetWorkerCleanerLock(poolName string) error
	RemoveWorkerCleanerLock(poolName string) error
}

func NewWorkerPoolRedisRepository

func NewWorkerPoolRedisRepository(rdb *common.RedisClient) WorkerPoolRepository

func NewWorkerPoolRedisRepositoryForTest

func NewWorkerPoolRedisRepositoryForTest(rdb *common.RedisClient) WorkerPoolRepository

type WorkerRedisRepository

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

func (*WorkerRedisRepository) AddContainerToWorker

func (r *WorkerRedisRepository) AddContainerToWorker(workerId string, containerId string) error

func (*WorkerRedisRepository) AddWorker

func (r *WorkerRedisRepository) AddWorker(worker *types.Worker) error

AddWorker adds or updates a worker

func (*WorkerRedisRepository) CordonAllPendingWorkersInPool

func (r *WorkerRedisRepository) CordonAllPendingWorkersInPool(poolName string) error

func (*WorkerRedisRepository) GetAllWorkers

func (r *WorkerRedisRepository) GetAllWorkers() ([]*types.Worker, error)

func (*WorkerRedisRepository) GetAllWorkersInPool

func (r *WorkerRedisRepository) GetAllWorkersInPool(poolName string) ([]*types.Worker, error)

func (*WorkerRedisRepository) GetAllWorkersOnMachine

func (r *WorkerRedisRepository) GetAllWorkersOnMachine(machineId string) ([]*types.Worker, error)

func (*WorkerRedisRepository) GetContainerIp

func (r *WorkerRedisRepository) GetContainerIp(networkPrefix string, containerId string) (string, error)

func (*WorkerRedisRepository) GetContainerIps

func (r *WorkerRedisRepository) GetContainerIps(networkPrefix string) ([]string, error)

func (*WorkerRedisRepository) GetFreeGpuCounts

func (r *WorkerRedisRepository) GetFreeGpuCounts() (map[string]int, error)

func (*WorkerRedisRepository) GetGpuAvailability

func (r *WorkerRedisRepository) GetGpuAvailability() (map[string]bool, error)

func (*WorkerRedisRepository) GetGpuCounts

func (r *WorkerRedisRepository) GetGpuCounts() (map[string]int, error)

func (*WorkerRedisRepository) GetId

func (r *WorkerRedisRepository) GetId() string

func (*WorkerRedisRepository) GetNextContainerRequest

func (r *WorkerRedisRepository) GetNextContainerRequest(workerId string) (*types.ContainerRequest, error)

func (*WorkerRedisRepository) GetPreemptibleGpus

func (r *WorkerRedisRepository) GetPreemptibleGpus() []string

func (*WorkerRedisRepository) GetWorkerById

func (r *WorkerRedisRepository) GetWorkerById(workerId string) (*types.Worker, error)

func (*WorkerRedisRepository) RemoveContainerFromWorker

func (r *WorkerRedisRepository) RemoveContainerFromWorker(workerId string, containerId string) error

func (*WorkerRedisRepository) RemoveContainerIp

func (r *WorkerRedisRepository) RemoveContainerIp(networkPrefix string, containerId string) error

func (*WorkerRedisRepository) RemoveImagePullLock

func (r *WorkerRedisRepository) RemoveImagePullLock(workerId, imageId, token string) error

func (*WorkerRedisRepository) RemoveNetworkLock

func (r *WorkerRedisRepository) RemoveNetworkLock(networkPrefix string, token string) error

func (*WorkerRedisRepository) RemoveWorker

func (r *WorkerRedisRepository) RemoveWorker(workerId string) error

func (*WorkerRedisRepository) ScheduleContainerRequest

func (r *WorkerRedisRepository) ScheduleContainerRequest(worker *types.Worker, request *types.ContainerRequest) error

func (*WorkerRedisRepository) SetContainerIp

func (r *WorkerRedisRepository) SetContainerIp(networkPrefix string, containerId, containerIp string) error

func (*WorkerRedisRepository) SetContainerResourceValues

func (r *WorkerRedisRepository) SetContainerResourceValues(workerId string, containerId string, usage types.ContainerResourceUsage) error

func (*WorkerRedisRepository) SetImagePullLock

func (r *WorkerRedisRepository) SetImagePullLock(workerId, imageId string) (string, error)

func (*WorkerRedisRepository) SetNetworkLock

func (r *WorkerRedisRepository) SetNetworkLock(networkPrefix string, ttl, retries int) (string, error)

func (*WorkerRedisRepository) SetWorkerKeepAlive

func (r *WorkerRedisRepository) SetWorkerKeepAlive(workerId string) error

func (*WorkerRedisRepository) ToggleWorkerAvailable

func (r *WorkerRedisRepository) ToggleWorkerAvailable(workerId string) error

func (*WorkerRedisRepository) UpdateWorkerCapacity

func (r *WorkerRedisRepository) UpdateWorkerCapacity(worker *types.Worker, request *types.ContainerRequest, CapacityUpdateType types.CapacityUpdateType) error

func (*WorkerRedisRepository) UpdateWorkerStatus

func (r *WorkerRedisRepository) UpdateWorkerStatus(workerId string, status types.WorkerStatus) error

type WorkerRepository

type WorkerRepository interface {
	GetId() string
	GetWorkerById(workerId string) (*types.Worker, error)
	GetAllWorkers() ([]*types.Worker, error)
	GetAllWorkersInPool(poolName string) ([]*types.Worker, error)
	CordonAllPendingWorkersInPool(poolName string) error
	GetAllWorkersOnMachine(machineId string) ([]*types.Worker, error)
	AddWorker(w *types.Worker) error
	ToggleWorkerAvailable(workerId string) error
	UpdateWorkerStatus(workerId string, status types.WorkerStatus) error
	RemoveWorker(workerId string) error
	SetWorkerKeepAlive(workerId string) error
	UpdateWorkerCapacity(w *types.Worker, cr *types.ContainerRequest, ut types.CapacityUpdateType) error
	ScheduleContainerRequest(worker *types.Worker, request *types.ContainerRequest) error
	GetNextContainerRequest(workerId string) (*types.ContainerRequest, error)
	AddContainerToWorker(workerId string, containerId string) error
	RemoveContainerFromWorker(workerId string, containerId string) error
	SetContainerResourceValues(workerId string, containerId string, usage types.ContainerResourceUsage) error
	SetImagePullLock(workerId, imageId string) (string, error)
	RemoveImagePullLock(workerId, imageId, token string) error
	GetContainerIp(networkPrefix string, containerId string) (string, error)
	SetContainerIp(networkPrefix string, containerId, containerIp string) error
	RemoveContainerIp(networkPrefix string, containerId string) error
	GetContainerIps(networkPrefix string) ([]string, error)
	SetNetworkLock(networkPrefix string, ttl, retries int) (string, error)
	RemoveNetworkLock(networkPrefix string, token string) error
	GetGpuCounts() (map[string]int, error)
	GetGpuAvailability() (map[string]bool, error)
	GetFreeGpuCounts() (map[string]int, error)
	GetPreemptibleGpus() []string
}

func NewWorkerRedisRepository

func NewWorkerRedisRepository(r *common.RedisClient, config types.WorkerConfig) WorkerRepository

func NewWorkerRedisRepositoryForTest

func NewWorkerRedisRepositoryForTest(rdb *common.RedisClient) WorkerRepository

type WorkspaceRedisRepository

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

func (*WorkspaceRedisRepository) AuthorizeToken

func (wr *WorkspaceRedisRepository) AuthorizeToken(token string) (*types.Token, *types.Workspace, error)

func (*WorkspaceRedisRepository) GetConcurrencyLimitByWorkspaceId

func (wr *WorkspaceRedisRepository) GetConcurrencyLimitByWorkspaceId(workspaceId string) (*types.ConcurrencyLimit, error)

func (*WorkspaceRedisRepository) RevokeToken

func (wr *WorkspaceRedisRepository) RevokeToken(tokenKey string) error

func (*WorkspaceRedisRepository) SetAuthorizationToken

func (wr *WorkspaceRedisRepository) SetAuthorizationToken(token *types.Token, workspace *types.Workspace) error

func (*WorkspaceRedisRepository) SetConcurrencyLimitByWorkspaceId

func (wr *WorkspaceRedisRepository) SetConcurrencyLimitByWorkspaceId(workspaceId string, limit *types.ConcurrencyLimit) error

type WorkspaceRepository

type WorkspaceRepository interface {
	GetConcurrencyLimitByWorkspaceId(workspaceId string) (*types.ConcurrencyLimit, error)
	SetConcurrencyLimitByWorkspaceId(workspaceId string, limit *types.ConcurrencyLimit) error
	AuthorizeToken(string) (*types.Token, *types.Workspace, error)
	RevokeToken(tokenKey string) error
	SetAuthorizationToken(*types.Token, *types.Workspace) error
}

func NewWorkspaceRedisRepository

func NewWorkspaceRedisRepository(r *common.RedisClient) WorkspaceRepository

func NewWorkspaceRedisRepositoryForTest

func NewWorkspaceRedisRepositoryForTest(rdb *common.RedisClient) WorkspaceRepository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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