repository

package
v0.0.0-...-4224abf Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScheduledJobsChannel = "jobs"
)

Variables

View Source
var (
	ErrEventReadUnsupported  = errors.New("event read unsupported")
	ErrEventWriteUnsupported = errors.New("event write unsupported")
)
View Source
var PostgresDataError = pq.ErrorClass("22")

Functions

func GenerateDSN

func GenerateDSN(config types.PostgresConfig) string

func NewCacheRedisRepository

func NewCacheRedisRepository(rdb *common.RedisClient) cache.CoordinatorRepository

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)
	ListLatestDeploymentsByAppIDs(ctx context.Context, workspaceID uint, appExternalIDs []string) (map[string]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)
	ListLatestStubsByAppIDs(ctx context.Context, workspaceID uint, appExternalIDs []string) (map[string]types.StubWithRelated, error)
	ListAppIDsByStubExternalIDs(ctx context.Context, workspaceID string, stubExternalIDs []string) (map[string]string, 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)
	ListStaleCheckpoints(ctx context.Context, activeRecentStubKeys []string, stubLastUsedBefore time.Time) ([]types.Checkpoint, error)
	PruneCheckpoints(ctx context.Context, checkpointIds []string) ([]types.Checkpoint, error)
}

func NewBackendPostgresRepositoryForTest

func NewBackendPostgresRepositoryForTest() (BackendRepository, sqlmock.Sqlmock)

type CacheRedisRepository

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

func (*CacheRedisRepository) CountCacheRegistrations

func (r *CacheRedisRepository) CountCacheRegistrations(ctx context.Context, logicalHostID string) (int64, error)

func (*CacheRedisRepository) GetActiveCacheRegistration

func (r *CacheRedisRepository) GetActiveCacheRegistration(ctx context.Context, logicalHostID string) (string, bool, error)

func (*CacheRedisRepository) GetCacheLogicalHost

func (r *CacheRedisRepository) GetCacheLogicalHost(ctx context.Context, logicalHostID string) (cache.CoordinatorHost, bool, error)

func (*CacheRedisRepository) GetCacheRegistration

func (r *CacheRedisRepository) GetCacheRegistration(ctx context.Context, logicalHostID, registrationID string) (cache.CoordinatorHost, bool, error)

func (*CacheRedisRepository) ListCacheLogicalHosts

func (r *CacheRedisRepository) ListCacheLogicalHosts(ctx context.Context, poolName, locality string) ([]string, error)

func (*CacheRedisRepository) ListCacheRegistrations

func (r *CacheRedisRepository) ListCacheRegistrations(ctx context.Context, logicalHostID string) ([]string, error)

func (*CacheRedisRepository) RemoveCacheLogicalHost

func (r *CacheRedisRepository) RemoveCacheLogicalHost(ctx context.Context, poolName, locality, logicalHostID string) error

func (*CacheRedisRepository) RemoveCacheRegistration

func (r *CacheRedisRepository) RemoveCacheRegistration(ctx context.Context, logicalHostID, registrationID string) error

func (*CacheRedisRepository) SetActiveCacheRegistration

func (r *CacheRedisRepository) SetActiveCacheRegistration(ctx context.Context, logicalHostID, registrationID string, ttl time.Duration) error

func (*CacheRedisRepository) SetCacheRegistration

func (r *CacheRedisRepository) SetCacheRegistration(ctx context.Context, host cache.CoordinatorHost, ttl time.Duration) error

type ComputeRedisRepository

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

func (*ComputeRedisRepository) DeleteAgentMachineState

func (r *ComputeRedisRepository) DeleteAgentMachineState(ctx context.Context, workspaceID, poolName, machineID string) error

func (*ComputeRedisRepository) DeleteAgentWorkerSlotState

func (r *ComputeRedisRepository) DeleteAgentWorkerSlotState(ctx context.Context, workspaceID, poolName, machineID, workerID string) error

func (*ComputeRedisRepository) DeletePoolState

func (r *ComputeRedisRepository) DeletePoolState(ctx context.Context, workspaceID, name string) error

func (*ComputeRedisRepository) GetAgentMachineState

func (r *ComputeRedisRepository) GetAgentMachineState(ctx context.Context, workspaceID, poolName, machineID string) (*compute.AgentTokenState, error)

func (*ComputeRedisRepository) GetAgentMachineStateForWorkspace

func (r *ComputeRedisRepository) GetAgentMachineStateForWorkspace(ctx context.Context, workspaceID, machineID string) (*compute.AgentTokenState, error)

func (*ComputeRedisRepository) GetAgentTokenState

func (r *ComputeRedisRepository) GetAgentTokenState(ctx context.Context, tokenHash string) (*compute.AgentTokenState, error)

func (*ComputeRedisRepository) GetJoinTokenState

func (r *ComputeRedisRepository) GetJoinTokenState(ctx context.Context, tokenHash string) (*compute.JoinTokenState, error)

func (*ComputeRedisRepository) GetPoolState

func (r *ComputeRedisRepository) GetPoolState(ctx context.Context, workspaceID, name string) (*compute.PoolState, error)

func (*ComputeRedisRepository) ListAgentTokenStates

func (r *ComputeRedisRepository) ListAgentTokenStates(ctx context.Context, workspaceID, poolName string) ([]*compute.AgentTokenState, error)

func (*ComputeRedisRepository) ListAgentWorkerSlotStates

func (r *ComputeRedisRepository) ListAgentWorkerSlotStates(ctx context.Context, workspaceID, poolName, machineID string) ([]*compute.AgentWorkerSlotState, error)

func (*ComputeRedisRepository) ListAllPoolStates

func (r *ComputeRedisRepository) ListAllPoolStates(ctx context.Context, limit int) ([]*compute.PoolState, error)

func (*ComputeRedisRepository) ListPoolStates

func (r *ComputeRedisRepository) ListPoolStates(ctx context.Context, workspaceID string, limit int) ([]*compute.PoolState, error)

func (*ComputeRedisRepository) LockPoolState

func (r *ComputeRedisRepository) LockPoolState(ctx context.Context, workspaceID, name string) error

LockPoolState serializes pool state writes across the reconciler, launch, and release paths.

func (*ComputeRedisRepository) PruneAgentMachineIndex

func (r *ComputeRedisRepository) PruneAgentMachineIndex(ctx context.Context, workspaceID, poolName string) error

PruneAgentMachineIndex removes index entries whose machine state key no longer exists.

func (*ComputeRedisRepository) SaveAgentTokenState

func (r *ComputeRedisRepository) SaveAgentTokenState(ctx context.Context, state *compute.AgentTokenState, ttl time.Duration) error

func (*ComputeRedisRepository) SaveAgentWorkerSlotState

func (r *ComputeRedisRepository) SaveAgentWorkerSlotState(ctx context.Context, state *compute.AgentWorkerSlotState) error

func (*ComputeRedisRepository) SaveJoinTokenState

func (r *ComputeRedisRepository) SaveJoinTokenState(ctx context.Context, state *compute.JoinTokenState, ttl time.Duration) error

func (*ComputeRedisRepository) SavePoolState

func (r *ComputeRedisRepository) SavePoolState(ctx context.Context, workspaceID string, state *compute.PoolState) error

func (*ComputeRedisRepository) UnlockPoolState

func (r *ComputeRedisRepository) UnlockPoolState(ctx context.Context, workspaceID, name string) error

type ComputeRepository

type ComputeRepository interface {
	LockPoolState(ctx context.Context, workspaceID, name string) error
	UnlockPoolState(ctx context.Context, workspaceID, name string) error
	SavePoolState(ctx context.Context, workspaceID string, state *compute.PoolState) error
	GetPoolState(ctx context.Context, workspaceID, name string) (*compute.PoolState, error)
	ListPoolStates(ctx context.Context, workspaceID string, limit int) ([]*compute.PoolState, error)
	ListAllPoolStates(ctx context.Context, limit int) ([]*compute.PoolState, error)
	DeletePoolState(ctx context.Context, workspaceID, name string) error
	SaveJoinTokenState(ctx context.Context, state *compute.JoinTokenState, ttl time.Duration) error
	GetJoinTokenState(ctx context.Context, tokenHash string) (*compute.JoinTokenState, error)
	SaveAgentTokenState(ctx context.Context, state *compute.AgentTokenState, ttl time.Duration) error
	GetAgentTokenState(ctx context.Context, tokenHash string) (*compute.AgentTokenState, error)
	GetAgentMachineState(ctx context.Context, workspaceID, poolName, machineID string) (*compute.AgentTokenState, error)
	GetAgentMachineStateForWorkspace(ctx context.Context, workspaceID, machineID string) (*compute.AgentTokenState, error)
	ListAgentTokenStates(ctx context.Context, workspaceID, poolName string) ([]*compute.AgentTokenState, error)
	DeleteAgentMachineState(ctx context.Context, workspaceID, poolName, machineID string) error
	PruneAgentMachineIndex(ctx context.Context, workspaceID, poolName string) error
	SaveAgentWorkerSlotState(ctx context.Context, state *compute.AgentWorkerSlotState) error
	ListAgentWorkerSlotStates(ctx context.Context, workspaceID, poolName, machineID string) ([]*compute.AgentWorkerSlotState, error)
	DeleteAgentWorkerSlotState(ctx context.Context, workspaceID, poolName, machineID, workerID string) error
}

func NewComputeRedisRepository

func NewComputeRedisRepository(rdb *common.RedisClient) ComputeRepository

type ContainerRedisRepository

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

func (*ContainerRedisRepository) AcquireEndpointRequestToken

func (c *ContainerRedisRepository) AcquireEndpointRequestToken(ctx context.Context, workspaceName, stubId, containerId string, maxTokens int, ttl time.Duration) (bool, error)

func (*ContainerRedisRepository) CheckContainerConcurrencyLimit

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

func (*ContainerRedisRepository) DeleteBackendRoutesByContainerID

func (cr *ContainerRedisRepository) DeleteBackendRoutesByContainerID(ctx context.Context, containerID string) error

func (*ContainerRedisRepository) DeleteBackendRoutesByMachine

func (cr *ContainerRedisRepository) DeleteBackendRoutesByMachine(ctx context.Context, workspaceID, poolName, machineID string) error

DeleteBackendRoutesByMachine removes all backend routes and index entries for a machine when it is released.

func (*ContainerRedisRepository) DeleteContainerState

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

func (*ContainerRedisRepository) DeleteStubState

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

func (*ContainerRedisRepository) EndpointRequestHeartbeatExists

func (c *ContainerRedisRepository) EndpointRequestHeartbeatExists(ctx context.Context, workspaceName, stubId, taskId, containerId string) (bool, 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) GetBackendRoute

func (cr *ContainerRedisRepository) GetBackendRoute(ctx context.Context, routeID string) (*types.BackendRoute, 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) GetEndpointRequestTokens

func (c *ContainerRedisRepository) GetEndpointRequestTokens(ctx context.Context, workspaceName, stubId, containerId string, maxTokens int, ttl time.Duration) (int, 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) ListBackendRoutesByMachine

func (cr *ContainerRedisRepository) ListBackendRoutesByMachine(ctx context.Context, workspaceID, poolName, machineID string) ([]types.BackendRoute, error)

func (*ContainerRedisRepository) PodKeepWarmLockExists

func (c *ContainerRedisRepository) PodKeepWarmLockExists(ctx context.Context, workspaceName, stubId, containerId string) (bool, error)

func (*ContainerRedisRepository) RefreshEndpointRequestTokenTTL

func (c *ContainerRedisRepository) RefreshEndpointRequestTokenTTL(ctx context.Context, workspaceName, stubId, containerId string, ttl time.Duration) error

func (*ContainerRedisRepository) ReleaseEndpointRequestToken

func (c *ContainerRedisRepository) ReleaseEndpointRequestToken(ctx context.Context, workspaceName, stubId, containerId, taskId string, maxTokens int, ttl time.Duration) error

func (*ContainerRedisRepository) SetBackendRoute

func (cr *ContainerRedisRepository) SetBackendRoute(ctx context.Context, route types.BackendRoute) error

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) SetEndpointRequestHeartbeat

func (c *ContainerRedisRepository) SetEndpointRequestHeartbeat(ctx context.Context, workspaceName, stubId, taskId, containerId string, ttl time.Duration) error

func (*ContainerRedisRepository) SetPodKeepWarmLock

func (c *ContainerRedisRepository) SetPodKeepWarmLock(ctx context.Context, workspaceName, stubId, containerId string, keepWarmSeconds int) 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)
	SetBackendRoute(ctx context.Context, route types.BackendRoute) error
	GetBackendRoute(ctx context.Context, routeID string) (*types.BackendRoute, error)
	ListBackendRoutesByMachine(ctx context.Context, workspaceID, poolName, machineID string) ([]types.BackendRoute, error)
	DeleteBackendRoutesByContainerID(ctx context.Context, containerID string) error
	DeleteBackendRoutesByMachine(ctx context.Context, workspaceID, poolName, machineID 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)
	CheckContainerConcurrencyLimit(quota *types.ConcurrencyLimit, request *types.ContainerRequest) 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
	GetEndpointRequestTokens(ctx context.Context, workspaceName, stubId, containerId string, maxTokens int, ttl time.Duration) (int, error)
	AcquireEndpointRequestToken(ctx context.Context, workspaceName, stubId, containerId string, maxTokens int, ttl time.Duration) (bool, error)
	ReleaseEndpointRequestToken(ctx context.Context, workspaceName, stubId, containerId, taskId string, maxTokens int, ttl time.Duration) error
	RefreshEndpointRequestTokenTTL(ctx context.Context, workspaceName, stubId, containerId string, ttl time.Duration) error
	SetEndpointRequestHeartbeat(ctx context.Context, workspaceName, stubId, taskId, containerId string, ttl time.Duration) error
	EndpointRequestHeartbeatExists(ctx context.Context, workspaceName, stubId, taskId, containerId string) (bool, error)
	SetPodKeepWarmLock(ctx context.Context, workspaceName, stubId, containerId string, keepWarmSeconds int) error
	PodKeepWarmLockExists(ctx context.Context, workspaceName, stubId, containerId string) (bool, error)
}

func NewContainerRedisRepository

func NewContainerRedisRepository(r *common.RedisClient) ContainerRepository

func NewContainerRedisRepositoryForTest

func NewContainerRedisRepositoryForTest(rdb *common.RedisClient) ContainerRepository

type EventClientRepo

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

func (*EventClientRepo) GetContainerEvents

func (r *EventClientRepo) GetContainerEvents(ctx context.Context, containerID string, query types.EventQuery) (*types.ContainerEventsResponse, error)

func (*EventClientRepo) GetEventHistory

func (r *EventClientRepo) GetEventHistory(ctx context.Context, query types.EventQuery) (*types.EventHistoryResponse, error)

func (*EventClientRepo) GetLogs

func (r *EventClientRepo) GetLogs(ctx context.Context, query types.LogQuery) (*types.LogsResponse, error)

func (*EventClientRepo) GetStubMetricsTimeseries

func (r *EventClientRepo) GetStubMetricsTimeseries(ctx context.Context, query types.EventQuery, start time.Time, end time.Time, interval string) (*types.MetricsTimeseriesResponse, error)

func (*EventClientRepo) GetWorkspaceMetricsTimeseries

func (r *EventClientRepo) GetWorkspaceMetricsTimeseries(ctx context.Context, query types.EventQuery, start time.Time, end time.Time, interval string) (*types.MetricsTimeseriesResponse, error)

func (*EventClientRepo) PushCloneStubEvent

func (r *EventClientRepo) PushCloneStubEvent(workspaceId string, stub *types.Stub, parentStub *types.Stub)

func (*EventClientRepo) PushComputeEvent

func (r *EventClientRepo) PushComputeEvent(eventType string, event types.EventComputeSchema)

func (*EventClientRepo) PushContainerEvent

func (r *EventClientRepo) PushContainerEvent(event types.EventContainerEventSchema)

func (*EventClientRepo) PushContainerFunctionTaskEvent

func (r *EventClientRepo) PushContainerFunctionTaskEvent(workspaceID string, task types.TaskInterface, eventID types.ContainerEventID, opts types.ContainerEventOptions)

func (*EventClientRepo) PushContainerFunctionTaskLifecycle

func (r *EventClientRepo) PushContainerFunctionTaskLifecycle(workspaceID string, task types.TaskInterface, lifecycleID types.ContainerLifecycleID, start time.Time, end time.Time, success bool, opts types.ContainerLifecycleOptions)

func (*EventClientRepo) PushContainerLifecycleEvent

func (r *EventClientRepo) PushContainerLifecycleEvent(lifecycle types.EventContainerLifecycleSchema)

func (*EventClientRepo) PushContainerLogDropped

func (r *EventClientRepo) PushContainerLogDropped(workerID string, request *types.ContainerRequest, message types.EventMessage, taskID string)

func (*EventClientRepo) PushContainerLogEvent

func (r *EventClientRepo) PushContainerLogEvent(entry types.EventContainerLogSchema)

func (*EventClientRepo) PushContainerLogEventQueued

func (r *EventClientRepo) PushContainerLogEventQueued(entry types.EventContainerLogSchema) error

func (*EventClientRepo) PushContainerLogFirstByte

func (r *EventClientRepo) PushContainerLogFirstByte(workerID string, request *types.ContainerRequest, taskID string)

func (*EventClientRepo) PushContainerLogFlushCompleted

func (r *EventClientRepo) PushContainerLogFlushCompleted(workerID string, request *types.ContainerRequest)

func (*EventClientRepo) PushContainerLogLastByte

func (r *EventClientRepo) PushContainerLogLastByte(workerID string, request *types.ContainerRequest)

func (*EventClientRepo) PushContainerRequestEvent

func (r *EventClientRepo) PushContainerRequestEvent(workerID string, request *types.ContainerRequest, eventID types.ContainerEventID, opts types.ContainerEventOptions)

func (*EventClientRepo) PushContainerRequestLifecycle

func (r *EventClientRepo) PushContainerRequestLifecycle(workerID string, request *types.ContainerRequest, lifecycleID types.ContainerLifecycleID, startedAt time.Time, duration time.Duration, success bool, opts types.ContainerLifecycleOptions)

func (*EventClientRepo) PushContainerRequestLogLine

func (r *EventClientRepo) PushContainerRequestLogLine(workerID string, request *types.ContainerRequest, taskID string, stream string, line string)

func (*EventClientRepo) PushContainerResourceMetricsEvent

func (r *EventClientRepo) PushContainerResourceMetricsEvent(workerID string, request *types.ContainerRequest, metrics types.EventContainerMetricsData)

func (*EventClientRepo) PushContainerRunnerEvent

func (r *EventClientRepo) PushContainerRunnerEvent(workerID string, request *types.ContainerRequest, event *types.ContainerRunnerEvent)

func (*EventClientRepo) PushContainerRunningToStartTask

func (r *EventClientRepo) PushContainerRunningToStartTask(task *types.TaskWithRelated, runningAt time.Time, startedAt time.Time, status types.ContainerStatus)

func (*EventClientRepo) PushContainerTaskEvent

func (r *EventClientRepo) PushContainerTaskEvent(task *types.TaskWithRelated, eventID types.ContainerEventID, opts types.ContainerEventOptions)

func (*EventClientRepo) PushContainerTaskLifecycle

func (r *EventClientRepo) PushContainerTaskLifecycle(task *types.TaskWithRelated, lifecycleID types.ContainerLifecycleID, start time.Time, end time.Time, success bool, opts types.ContainerLifecycleOptions)

func (*EventClientRepo) PushContainerTaskLifecycleSince

func (r *EventClientRepo) PushContainerTaskLifecycleSince(ctx context.Context, rdb *common.RedisClient, task *types.TaskWithRelated, lifecycleID types.ContainerLifecycleID, sincePhase string, end time.Time, success bool, opts types.ContainerLifecycleOptions)

func (*EventClientRepo) PushDeployStubEvent

func (r *EventClientRepo) PushDeployStubEvent(workspaceId string, stub *types.Stub)

func (*EventClientRepo) PushFunctionGetArgs

func (r *EventClientRepo) PushFunctionGetArgs(ctx context.Context, rdb *common.RedisClient, task *types.TaskWithRelated, at time.Time, byteCount int)

func (*EventClientRepo) PushFunctionResultDelivery

func (r *EventClientRepo) PushFunctionResultDelivery(workspaceID string, task types.TaskInterface, startedAt time.Time, exitCode int32, byteCount int)

func (*EventClientRepo) PushFunctionResultLoaded

func (r *EventClientRepo) PushFunctionResultLoaded(workspaceID string, task types.TaskInterface, exitCode int32, byteCount int)

func (*EventClientRepo) PushFunctionResultSent

func (r *EventClientRepo) PushFunctionResultSent(workspaceID string, task types.TaskInterface, exitCode int32, byteCount int)

func (*EventClientRepo) PushFunctionSetResult

func (r *EventClientRepo) PushFunctionSetResult(ctx context.Context, rdb *common.RedisClient, task *types.TaskWithRelated, at time.Time, byteCount int)

func (*EventClientRepo) PushFunctionStreamCancelApplied

func (r *EventClientRepo) PushFunctionStreamCancelApplied(workspaceID string, task types.TaskInterface)

func (*EventClientRepo) PushFunctionStreamCancelRequested

func (r *EventClientRepo) PushFunctionStreamCancelRequested(workspaceID string, task types.TaskInterface)

func (*EventClientRepo) PushGatewayEndpointCalledEvent

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

func (*EventClientRepo) PushPlatformCacheEvent

func (r *EventClientRepo) PushPlatformCacheEvent(schema types.EventPlatformCacheSchema)

func (*EventClientRepo) PushPlatformLogEvent

func (r *EventClientRepo) PushPlatformLogEvent(entry types.EventPlatformLogSchema)

func (*EventClientRepo) PushRunStubEvent

func (r *EventClientRepo) PushRunStubEvent(workspaceId string, stub *types.Stub)

func (*EventClientRepo) PushServeStubEvent

func (r *EventClientRepo) PushServeStubEvent(workspaceId string, stub *types.Stub)

func (*EventClientRepo) PushStubCacheRequiredContent

func (r *EventClientRepo) PushStubCacheRequiredContent(schema types.EventStubCacheRequiredContentSchema) error

func (*EventClientRepo) PushStubStateUnhealthy

func (r *EventClientRepo) PushStubStateUnhealthy(workspaceId string, stubId string, currentState string, previousState string, reason string, failedContainers []string)

func (*EventClientRepo) PushTaskCancelApplied

func (r *EventClientRepo) PushTaskCancelApplied(task *types.TaskWithRelated, source types.EventSource, message types.EventMessage)

func (*EventClientRepo) PushTaskCancelRequested

func (r *EventClientRepo) PushTaskCancelRequested(task *types.TaskWithRelated, source types.EventSource, message types.EventMessage)

func (*EventClientRepo) PushTaskCreatedEvent

func (r *EventClientRepo) PushTaskCreatedEvent(task *types.TaskWithRelated)

func (*EventClientRepo) PushTaskEndEvents

func (r *EventClientRepo) PushTaskEndEvents(ctx context.Context, rdb *common.RedisClient, task *types.TaskWithRelated, endedAt time.Time)

func (*EventClientRepo) PushTaskEndPersisted

func (r *EventClientRepo) PushTaskEndPersisted(task *types.TaskWithRelated)

func (*EventClientRepo) PushTaskStartEvents

func (r *EventClientRepo) PushTaskStartEvents(ctx context.Context, rdb *common.RedisClient, task *types.TaskWithRelated, containerID string, startedAt time.Time)

func (*EventClientRepo) PushTaskUpdatedEvent

func (r *EventClientRepo) PushTaskUpdatedEvent(task *types.TaskWithRelated)

func (*EventClientRepo) PushWorkerDeletedEvent

func (r *EventClientRepo) PushWorkerDeletedEvent(workerID, machineID, poolName string, reason types.DeletedWorkerReason)

func (*EventClientRepo) PushWorkerPoolDegradedEvent

func (r *EventClientRepo) PushWorkerPoolDegradedEvent(poolName string, reasons []string, poolState *types.WorkerPoolState)

func (*EventClientRepo) PushWorkerPoolHealthyEvent

func (r *EventClientRepo) PushWorkerPoolHealthyEvent(poolName string, poolState *types.WorkerPoolState)

func (*EventClientRepo) PushWorkerStartedEvent

func (r *EventClientRepo) PushWorkerStartedEvent(workerID string)

func (*EventClientRepo) PushWorkerStoppedEvent

func (r *EventClientRepo) PushWorkerStoppedEvent(workerID string)

func (*EventClientRepo) ReadStubCacheRequiredContent

func (r *EventClientRepo) ReadStubCacheRequiredContent(ctx context.Context, workspaceID, stubID string) ([]types.CacheRequiredContentItem, error)

func (*EventClientRepo) StreamAppNamespaceEvents

func (r *EventClientRepo) StreamAppNamespaceEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

func (*EventClientRepo) StreamContainerEvents

func (r *EventClientRepo) StreamContainerEvents(ctx context.Context, containerID string, query types.EventQuery) (EventStream, error)

func (*EventClientRepo) StreamLogs

func (r *EventClientRepo) StreamLogs(ctx context.Context, query types.LogQuery) (EventStream, error)

func (*EventClientRepo) StreamStubEvents

func (r *EventClientRepo) StreamStubEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

func (*EventClientRepo) StreamTaskEvents

func (r *EventClientRepo) StreamTaskEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

func (*EventClientRepo) StreamWorkspaceEvents

func (r *EventClientRepo) StreamWorkspaceEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

type EventRepository

type EventRepository interface {
	GetContainerEvents(ctx context.Context, containerID string, query types.EventQuery) (*types.ContainerEventsResponse, error)
	GetEventHistory(ctx context.Context, query types.EventQuery) (*types.EventHistoryResponse, error)
	GetLogs(ctx context.Context, query types.LogQuery) (*types.LogsResponse, error)
	GetStubMetricsTimeseries(ctx context.Context, query types.EventQuery, start time.Time, end time.Time, interval string) (*types.MetricsTimeseriesResponse, error)
	GetWorkspaceMetricsTimeseries(ctx context.Context, query types.EventQuery, start time.Time, end time.Time, interval string) (*types.MetricsTimeseriesResponse, error)
	StreamContainerEvents(ctx context.Context, containerID string, query types.EventQuery) (EventStream, error)
	StreamStubEvents(ctx context.Context, query types.EventQuery) (EventStream, error)
	StreamTaskEvents(ctx context.Context, query types.EventQuery) (EventStream, error)
	StreamWorkspaceEvents(ctx context.Context, query types.EventQuery) (EventStream, error)
	StreamAppNamespaceEvents(ctx context.Context, query types.EventQuery) (EventStream, error)
	StreamLogs(ctx context.Context, query types.LogQuery) (EventStream, error)
	PushContainerResourceMetricsEvent(workerID string, request *types.ContainerRequest, metrics types.EventContainerMetricsData)
	PushContainerLifecycleEvent(lifecycle types.EventContainerLifecycleSchema)
	PushContainerEvent(event types.EventContainerEventSchema)
	PushContainerLogEvent(entry types.EventContainerLogSchema)
	PushContainerLogEventQueued(entry types.EventContainerLogSchema) error
	PushPlatformLogEvent(entry types.EventPlatformLogSchema)
	PushContainerRequestEvent(workerID string, request *types.ContainerRequest, eventID types.ContainerEventID, opts types.ContainerEventOptions)
	PushContainerRequestLifecycle(workerID string, request *types.ContainerRequest, lifecycleID types.ContainerLifecycleID, startedAt time.Time, duration time.Duration, success bool, opts types.ContainerLifecycleOptions)
	PushContainerTaskEvent(task *types.TaskWithRelated, eventID types.ContainerEventID, opts types.ContainerEventOptions)
	PushContainerFunctionTaskEvent(workspaceID string, task types.TaskInterface, eventID types.ContainerEventID, opts types.ContainerEventOptions)
	PushContainerTaskLifecycle(task *types.TaskWithRelated, lifecycleID types.ContainerLifecycleID, start time.Time, end time.Time, success bool, opts types.ContainerLifecycleOptions)
	PushContainerFunctionTaskLifecycle(workspaceID string, task types.TaskInterface, lifecycleID types.ContainerLifecycleID, start time.Time, end time.Time, success bool, opts types.ContainerLifecycleOptions)
	PushContainerTaskLifecycleSince(ctx context.Context, rdb *pkgcommon.RedisClient, task *types.TaskWithRelated, lifecycleID types.ContainerLifecycleID, sincePhase string, end time.Time, success bool, opts types.ContainerLifecycleOptions)
	PushContainerRequestLogLine(workerID string, request *types.ContainerRequest, taskID string, stream string, line string)
	PushContainerRunnerEvent(workerID string, request *types.ContainerRequest, event *types.ContainerRunnerEvent)
	PushFunctionResultLoaded(workspaceID string, task types.TaskInterface, exitCode int32, byteCount int)
	PushFunctionResultSent(workspaceID string, task types.TaskInterface, exitCode int32, byteCount int)
	PushFunctionResultDelivery(workspaceID string, task types.TaskInterface, startedAt time.Time, exitCode int32, byteCount int)
	PushFunctionStreamCancelRequested(workspaceID string, task types.TaskInterface)
	PushFunctionStreamCancelApplied(workspaceID string, task types.TaskInterface)
	PushFunctionGetArgs(ctx context.Context, rdb *pkgcommon.RedisClient, task *types.TaskWithRelated, at time.Time, byteCount int)
	PushFunctionSetResult(ctx context.Context, rdb *pkgcommon.RedisClient, task *types.TaskWithRelated, at time.Time, byteCount int)
	PushTaskStartEvents(ctx context.Context, rdb *pkgcommon.RedisClient, task *types.TaskWithRelated, containerID string, startedAt time.Time)
	PushTaskEndEvents(ctx context.Context, rdb *pkgcommon.RedisClient, task *types.TaskWithRelated, endedAt time.Time)
	PushTaskEndPersisted(task *types.TaskWithRelated)
	PushContainerRunningToStartTask(task *types.TaskWithRelated, runningAt time.Time, startedAt time.Time, status types.ContainerStatus)
	PushTaskCancelRequested(task *types.TaskWithRelated, source types.EventSource, message types.EventMessage)
	PushTaskCancelApplied(task *types.TaskWithRelated, source types.EventSource, message types.EventMessage)
	PushContainerLogFlushCompleted(workerID string, request *types.ContainerRequest)
	PushContainerLogDropped(workerID string, request *types.ContainerRequest, message types.EventMessage, taskID string)
	PushContainerLogFirstByte(workerID string, request *types.ContainerRequest, taskID string)
	PushContainerLogLastByte(workerID string, request *types.ContainerRequest)
	PushWorkerStartedEvent(workerID string)
	PushWorkerStoppedEvent(workerID string)
	PushWorkerDeletedEvent(workerID, machineID, poolName string, reason types.DeletedWorkerReason)
	PushComputeEvent(eventType string, event types.EventComputeSchema)
	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)
	PushStubCacheRequiredContent(schema types.EventStubCacheRequiredContentSchema) error
	PushPlatformCacheEvent(schema types.EventPlatformCacheSchema)
	ReadStubCacheRequiredContent(ctx context.Context, workspaceID, stubID string) ([]types.CacheRequiredContentItem, error)
}

func NewEventClientRepo

func NewEventClientRepo(config types.AppConfig) EventRepository

type EventStream

type EventStream interface {
	Next() bool
	Record() types.ContainerEventRecord
	Err() error
	Close() error
}

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) ListAppIDsByStubExternalIDs

func (c *PostgresBackendRepository) ListAppIDsByStubExternalIDs(ctx context.Context, workspaceID string, stubExternalIDs []string) (map[string]string, 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) ListLatestDeploymentsByAppIDs

func (c *PostgresBackendRepository) ListLatestDeploymentsByAppIDs(ctx context.Context, workspaceID uint, appExternalIDs []string) (map[string]types.DeploymentWithRelated, error)

func (*PostgresBackendRepository) ListLatestDeploymentsWithRelatedPaginated

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

func (*PostgresBackendRepository) ListLatestStubsByAppIDs

func (c *PostgresBackendRepository) ListLatestStubsByAppIDs(ctx context.Context, workspaceID uint, appExternalIDs []string) (map[string]types.StubWithRelated, error)

func (*PostgresBackendRepository) ListSecrets

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

func (*PostgresBackendRepository) ListStaleCheckpoints

func (r *PostgresBackendRepository) ListStaleCheckpoints(ctx context.Context, activeRecentStubKeys []string, stubLastUsedBefore time.Time) ([]types.Checkpoint, 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) PruneCheckpoints

func (r *PostgresBackendRepository) PruneCheckpoints(ctx context.Context, checkpointIds []string) ([]types.Checkpoint, 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 S2EventRepository

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

func NewS2EventRepository

func NewS2EventRepository(config types.S2Config) (*S2EventRepository, error)

func (*S2EventRepository) GetContainerEvents

func (r *S2EventRepository) GetContainerEvents(ctx context.Context, containerID string, query types.EventQuery) (*types.ContainerEventsResponse, error)

func (*S2EventRepository) GetEventHistory

func (r *S2EventRepository) GetEventHistory(ctx context.Context, query types.EventQuery) (*types.EventHistoryResponse, error)

func (*S2EventRepository) GetLogs

func (*S2EventRepository) GetStubMetricsTimeseries

func (r *S2EventRepository) GetStubMetricsTimeseries(ctx context.Context, query types.EventQuery, start time.Time, end time.Time, interval string) (*types.MetricsTimeseriesResponse, error)

func (*S2EventRepository) GetWorkspaceMetricsTimeseries

func (r *S2EventRepository) GetWorkspaceMetricsTimeseries(ctx context.Context, query types.EventQuery, start time.Time, end time.Time, interval string) (*types.MetricsTimeseriesResponse, error)

func (*S2EventRepository) PushEvent

func (r *S2EventRepository) PushEvent(event cloudevents.Event) error

func (*S2EventRepository) PushEventSync

func (r *S2EventRepository) PushEventSync(event cloudevents.Event) error

func (*S2EventRepository) ReadStubCacheRequiredContent

func (r *S2EventRepository) ReadStubCacheRequiredContent(ctx context.Context, workspaceID, stubID string) ([]types.CacheRequiredContentItem, error)

ReadStubCacheRequiredContent reads the coalesced required-content set for a stub from the dedicated S2 cache stream. Items are merged by (hash, routing_key) keeping the most recent report for each.

func (*S2EventRepository) StreamAppNamespaceEvents

func (r *S2EventRepository) StreamAppNamespaceEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

func (*S2EventRepository) StreamContainerEvents

func (r *S2EventRepository) StreamContainerEvents(ctx context.Context, containerID string, query types.EventQuery) (EventStream, error)

func (*S2EventRepository) StreamLogs

func (r *S2EventRepository) StreamLogs(ctx context.Context, query types.LogQuery) (EventStream, error)

func (*S2EventRepository) StreamStubEvents

func (r *S2EventRepository) StreamStubEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

func (*S2EventRepository) StreamTaskEvents

func (r *S2EventRepository) StreamTaskEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

func (*S2EventRepository) StreamWorkspaceEvents

func (r *S2EventRepository) StreamWorkspaceEvents(ctx context.Context, query types.EventQuery) (EventStream, error)

type SchedulerRepository

type SchedulerRepository interface{}

type ScopedS2EventRepository

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

func NewScopedS2EventRepository

func NewScopedS2EventRepository(config types.S2Config) (*ScopedS2EventRepository, error)

func (*ScopedS2EventRepository) PushEvent

func (r *ScopedS2EventRepository) PushEvent(event cloudevents.Event) error

func (*ScopedS2EventRepository) PushEventSync

func (r *ScopedS2EventRepository) PushEventSync(event cloudevents.Event) error

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) GetContainerIpAssignments

func (r *WorkerRedisRepository) GetContainerIpAssignments(networkPrefix string) ([]types.ContainerIpAssignment, 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) MoveContainerIp

func (r *WorkerRedisRepository) MoveContainerIp(networkPrefix, fromContainerId, toContainerId, containerIp string) 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
	MoveContainerIp(networkPrefix, fromContainerId, toContainerId, containerIp string) error
	RemoveContainerIp(networkPrefix string, containerId string) error
	GetContainerIps(networkPrefix string) ([]string, error)
	GetContainerIpAssignments(networkPrefix string) ([]types.ContainerIpAssignment, 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