repository

package
v0.0.0-...-f65cf3b Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: AGPL-3.0 Imports: 30 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)
	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)
	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)
	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) (types.Stub, error)
	GetStubByExternalId(ctx context.Context, externalId string, 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)
	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)
	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) (*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)
	CreateSecret(ctx context.Context, workspace *types.Workspace, tokenId uint, name string, value string) (*types.Secret, error)
	GetSecretByName(ctx context.Context, workspace *types.Workspace, name string) (*types.Secret, error)
	GetSecretByNameDecrypted(ctx context.Context, workspace *types.Workspace, name string) (*types.Secret, error)
	ListSecrets(ctx context.Context, workspace *types.Workspace) ([]types.Secret, error)
	UpdateSecret(ctx context.Context, workspace *types.Workspace, tokenId uint, secretId 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
}

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

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

func (*ContainerRedisRepository) GetContainerState

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

func (*ContainerRedisRepository) GetFailedContainerCountByStubId

func (cr *ContainerRedisRepository) GetFailedContainerCountByStubId(stubId string) (int, error)

func (*ContainerRedisRepository) GetWorkerAddress

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

func (*ContainerRedisRepository) SetContainerAddress

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

func (*ContainerRedisRepository) SetContainerExitCode

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

func (*ContainerRedisRepository) SetContainerState

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

func (*ContainerRedisRepository) SetContainerStateWithConcurrencyLimit

func (c *ContainerRedisRepository) SetContainerStateWithConcurrencyLimit(quota *types.ConcurrencyLimit, request *types.ContainerRequest) 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, expiry time.Duration) 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, time.Duration) error
	UpdateAssignedContainerGPU(string, string) error
	DeleteContainerState(containerId string) error
	SetWorkerAddress(containerId string, addr string) error
	SetContainerStateWithConcurrencyLimit(quota *types.ConcurrencyLimit, request *types.ContainerRequest) error
	GetWorkerAddress(ctx context.Context, containerId string) (string, error)
	GetActiveContainersByStubId(stubId string) ([]types.ContainerState, error)
	GetActiveContainersByWorkspaceId(workspaceId string) ([]types.ContainerState, error)
	GetActiveContainersByWorkerId(workerId string) ([]types.ContainerState, error)
	GetFailedContainerCountByStubId(stubId string) (int, error)
}

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)
	PushContainerResourceMetricsEvent(workerID string, request *types.ContainerRequest, metrics types.EventContainerMetricsData)
	PushWorkerStartedEvent(workerID string)
	PushWorkerStoppedEvent(workerID string)
	PushDeployStubEvent(workspaceId string, stub *types.Stub)
	PushServeStubEvent(workspaceId string, stub *types.Stub)
	PushRunStubEvent(workspaceId string, stub *types.Stub)
	PushTaskUpdatedEvent(task *types.TaskWithRelated)
	PushTaskCreatedEvent(task *types.TaskWithRelated)
}

func NewTCPEventClientRepo

func NewTCPEventClientRepo(config types.FluentBitEventConfig) EventRepository

type MetricsRepository

type MetricsRepository 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 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) 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) (*types.Deployment, 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) (*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) 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) 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) 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) 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) GetOrCreateStub

func (r *PostgresBackendRepository) GetOrCreateStub(ctx context.Context, name, stubType string, config types.StubConfigV1, objectId, workspaceId uint, forceCreate bool) (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) GetStubByExternalId

func (r *PostgresBackendRepository) GetStubByExternalId(ctx context.Context, externalId string, 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) GetTaskWithRelated

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

func (*PostgresBackendRepository) GetVolume

func (c *PostgresBackendRepository) GetVolume(ctx context.Context, workspaceId uint, name string) (*types.Volume, 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) 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) RevokeTokenByExternalId

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

func (*PostgresBackendRepository) ToggleToken

func (r *PostgresBackendRepository) ToggleToken(ctx context.Context, workspaceId uint, extTokenId string) (types.Token, 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, secretId string, value string) (*types.Secret, 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) 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) 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) 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)

func (*TCPEventClientRepo) PushDeployStubEvent

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

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

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

func (*TCPEventClientRepo) PushTaskUpdatedEvent

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

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

func (r *WorkerRedisRepository) GetId() string

func (*WorkerRedisRepository) GetNextContainerRequest

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

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 string) error

func (*WorkerRedisRepository) RemoveNetworkLock

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

func (*WorkerRedisRepository) RemoveWorker

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

func (*WorkerRedisRepository) RemoveWorkerPoolSizerLock

func (r *WorkerRedisRepository) RemoveWorkerPoolSizerLock(poolName 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) error

func (*WorkerRedisRepository) SetNetworkLock

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

func (*WorkerRedisRepository) SetWorkerKeepAlive

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

func (*WorkerRedisRepository) SetWorkerPoolSizerLock

func (r *WorkerRedisRepository) SetWorkerPoolSizerLock(poolName 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)
	GetAllWorkersOnMachine(machineId string) ([]*types.Worker, error)
	AddWorker(w *types.Worker) error
	ToggleWorkerAvailable(workerId string) error
	UpdateWorkerStatus(workerId string, status types.WorkerStatus) error
	RemoveWorker(w *types.Worker) 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) error
	RemoveImagePullLock(workerId, imageId 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) error
	RemoveNetworkLock(networkPrefix string) error
	SetWorkerPoolSizerLock(controllerName string) error
	RemoveWorkerPoolSizerLock(controllerName string) error
}

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