Documentation
¶
Overview ¶
Package service holds the process vertical's business rules: submitting a run under the caller's own identity, and recording what happened to it.
Index ¶
- type DataStagingTaskService
- type InteractiveCommandTaskService
- type JobMonitoringTaskService
- type JobSubmissionTaskService
- type LaunchService
- type LinkService
- func (s *LinkService) Authenticate(ctx context.Context, processID, token string) bool
- func (s *LinkService) Issue(ctx context.Context, processID string) (*link.Issued, error)
- func (s *LinkService) JupyterPort(ctx context.Context, processID, token string) (uint16, bool)
- func (s *LinkService) JupyterServer(ctx context.Context, processID string) (*dto.JupyterServerResponse, error)
- func (s *LinkService) LinkURL(processID string) (string, error)
- func (s *LinkService) Registry() *link.Registry
- type ProcessService
- func (s *ProcessService) Create(ctx context.Context, req *dto.Request) (*dto.Response, error)
- func (s *ProcessService) Delete(ctx context.Context, id string) error
- func (s *ProcessService) Get(ctx context.Context, id string) (*dto.Response, error)
- func (s *ProcessService) List(ctx context.Context) ([]dto.Response, error)
- func (s *ProcessService) ListByDeployment(ctx context.Context, deploymentID string) ([]dto.Response, error)
- func (s *ProcessService) ListMine(ctx context.Context) ([]dto.Response, error)
- func (s *ProcessService) Update(ctx context.Context, id string, req *dto.Request) (*dto.Response, error)
- type StatusService
- func (s *StatusService) Get(ctx context.Context, processID, statusID string) (*dto.StatusResponse, error)
- func (s *StatusService) ListForProcess(ctx context.Context, processID string) ([]dto.StatusResponse, error)
- func (s *StatusService) Record(ctx context.Context, processID string, status model.ProcessStatusType, ...) (*dto.StatusResponse, error)
- func (s *StatusService) RecordTx(ctx context.Context, tx *gorm.DB, processID string, ...) (*model.ProcessStatus, error)
- type TaskService
- func (s *TaskService[T, Req]) Create(ctx context.Context, processID string, req *Req) (*T, error)
- func (s *TaskService[T, Req]) Delete(ctx context.Context, processID, taskID string) error
- func (s *TaskService[T, Req]) Get(ctx context.Context, processID, taskID string) (*T, error)
- func (s *TaskService[T, Req]) ListForProcess(ctx context.Context, processID string) ([]T, error)
- func (s *TaskService[T, Req]) Update(ctx context.Context, processID, taskID string, req *Req) (*T, error)
- type TaskStatusService
- type WorkflowService
- func (s *WorkflowService) Get(ctx context.Context, processID, processWorkflowID string) (*dto.WorkflowResponse, error)
- func (s *WorkflowService) ListForProcess(ctx context.Context, processID string) ([]dto.WorkflowResponse, error)
- func (s *WorkflowService) Record(ctx context.Context, processID, workflowID string, ...) (*dto.WorkflowResponse, error)
- func (s *WorkflowService) RecordTx(ctx context.Context, tx *gorm.DB, processID, workflowID string, ...) (*model.ProcessWorkflow, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataStagingTaskService ¶
type DataStagingTaskService = TaskService[model.DataStagingTask, dto.DataStagingTaskRequest]
The four instantiations.
func NewDataStagingTaskService ¶
func NewDataStagingTaskService(db *gorm.DB, tasks *repository.DataStagingTaskRepository, processes *repository.ProcessRepository) *DataStagingTaskService
NewDataStagingTaskService returns a staging task service.
type InteractiveCommandTaskService ¶
type InteractiveCommandTaskService = TaskService[model.InteractiveCommandTask, dto.InteractiveCommandTaskRequest]
The four instantiations.
func NewInteractiveCommandTaskService ¶
func NewInteractiveCommandTaskService(db *gorm.DB, tasks *repository.InteractiveCommandTaskRepository, processes *repository.ProcessRepository) *InteractiveCommandTaskService
NewInteractiveCommandTaskService returns a command task service.
type JobMonitoringTaskService ¶
type JobMonitoringTaskService = TaskService[model.JobMonitoringTask, dto.JobMonitoringTaskRequest]
The four instantiations.
func NewJobMonitoringTaskService ¶
func NewJobMonitoringTaskService(db *gorm.DB, tasks *repository.JobMonitoringTaskRepository, processes *repository.ProcessRepository) *JobMonitoringTaskService
NewJobMonitoringTaskService returns a monitoring task service.
type JobSubmissionTaskService ¶
type JobSubmissionTaskService = TaskService[model.JobSubmissionTask, dto.JobSubmissionTaskRequest]
The four instantiations.
func NewJobSubmissionTaskService ¶
func NewJobSubmissionTaskService(db *gorm.DB, tasks *repository.JobSubmissionTaskRepository, processes *repository.ProcessRepository) *JobSubmissionTaskService
NewJobSubmissionTaskService returns a submission task service.
type LaunchService ¶
type LaunchService struct {
// contains filtered or unexported fields
}
func NewLaunchService ¶
func NewLaunchService( db *gorm.DB, processService *ProcessService, batchDeploymentService *appserv.BatchDeploymentService, templateService *appserv.TemplateService, clusterService *computesev.SlurmClusterService, clusterConfigService *computesev.SlurmClusterConfigService, sshCredentialService *credentialsev.SSHCredentialService, scpDataStorageService *datasev.SCPDataStorageService, dataProductService *datasev.DataProductService, statusService *StatusService, dataStagingTasks *repository.DataStagingTaskRepository, jobSubmissionTasks *repository.JobSubmissionTaskRepository, monitoringTasks *repository.JobMonitoringTaskRepository, interactiveTasks *repository.InteractiveCommandTaskRepository, processWorkflows *repository.WorkflowRepository, executionEngine *orchestration.ExecutionEngine, ) *LaunchService
NewLaunchService returns a launch service.
func (*LaunchService) LaunchProcess ¶
LaunchProcess turns a submitted process into the tasks that will carry it out.
Owner-scoped, like the task routes and unlike the process reads: launching acts on a host under the identity the run was submitted with, so it is the owner's to trigger. The references it walks — the cluster config, each data product — are authorised in turn by their own services, so a run cannot reach a config or a dataset its owner has no standing on either.
Launching is not idempotent: it writes a task per staged file plus a submission and a monitoring task, so a second call would double them. A process that already carries tasks is refused rather than launched again.
func (*LaunchService) RetryProcess ¶
RetryProcess starts again the workflow of a launched process that failed.
Only the failed workflow is run again: a process whose job was submitted but whose completion failed runs its completion workflow, not a second submission. Inside it, each task that already completed is passed over rather than repeated (see execution.TaskTracker.Track), so a retry picks up at the step that failed.
Owner-scoped like LaunchProcess, for the same reason. A process with a workflow still running, or none that failed, is refused with a conflict rather than started twice.
type LinkService ¶
type LinkService struct {
// contains filtered or unexported fields
}
LinkService makes Airavata the control plane a job's Linkspan links to, in the role cs-plane plays for CyberShuttle: it issues each submission its link and Jupyter tokens, admits the WebSocket that offers the link token, and opens the job's Jupyter Server to the process owner through a proxy.
func NewLinkService ¶
func NewLinkService(links *repository.LinkRepository, processes *repository.ProcessRepository, registry *link.Registry, publicURL string) *LinkService
NewLinkService returns a link service. publicURL is where jobs reach this server, http(s)://host[:port]; the link URL is its ws(s) form.
func (*LinkService) Authenticate ¶
func (s *LinkService) Authenticate(ctx context.Context, processID, token string) bool
Authenticate reports whether token is the link token last issued to the process.
func (*LinkService) Issue ¶
Issue mints the link and Jupyter tokens for a submission of the process, replacing any issued before, and returns what the job is handed.
func (*LinkService) JupyterPort ¶
JupyterPort returns the port of the process's Jupyter Server when token is its Jupyter token, and false otherwise.
func (*LinkService) JupyterServer ¶
func (s *LinkService) JupyterServer(ctx context.Context, processID string) (*dto.JupyterServerResponse, error)
JupyterServer returns the caller's access to their process's Jupyter Server. Only the owner may have it: the token runs code as the owner's cluster account.
func (*LinkService) LinkURL ¶
func (s *LinkService) LinkURL(processID string) (string, error)
LinkURL is the WebSocket URL a process's Linkspan dials.
func (*LinkService) Registry ¶
func (s *LinkService) Registry() *link.Registry
Registry is the live links this service admits.
type ProcessService ¶
type ProcessService struct {
// contains filtered or unexported fields
}
ProcessService manages processes: individual runs, of whatever kind.
Everything a run carries is managed from here. A batch process is written, read and deleted as a section of the process that owns it, never addressed on its own, so there is no service for it either — the API surface and the service surface say the same thing about what is a resource.
Note the asymmetry with cluster configs and SCP data. Submitting is self-service and ownership is taken from the token, but reads are not owner-scoped: listing by deployment and fetching by id carry no authorisation at all, matching the Java service. That is worth revisiting, but it is the behaviour clients have.
func NewProcessService ¶
func NewProcessService( db *gorm.DB, processes *repository.ProcessRepository, deployments *applicationrepo.BatchDeploymentRepository, configs *computesvc.ConfigAccess, users *iamrepo.UserRepository, statuses *StatusService, ) *ProcessService
NewProcessService returns a process service.
func (*ProcessService) Create ¶
Create submits a process for the calling user.
Any authenticated caller may submit for themselves — this is self-service, not an administrative operation — and the owner always comes from the token.
func (*ProcessService) Delete ¶
func (s *ProcessService) Delete(ctx context.Context, id string) error
Delete removes a process and everything it owns: its batch process and that section's resource request, its status history, its tasks and its mappings. Admin only.
func (*ProcessService) ListByDeployment ¶
func (s *ProcessService) ListByDeployment(ctx context.Context, deploymentID string) ([]dto.Response, error)
ListByDeployment returns every process run against one deployment.
func (*ProcessService) ListMine ¶
ListMine returns the caller's own processes. Unlike the unfiltered listing it needs no platform role: it is what a user monitoring their own runs reads.
func (*ProcessService) Update ¶
func (s *ProcessService) Update(ctx context.Context, id string, req *dto.Request) (*dto.Response, error)
Update is an administrative correction of a process: its deployment, the resources it asked for, or its template mappings.
Two things are deliberately immutable. Ownership, because re-deriving it from the caller's token would reassign the process to whichever admin issued the request. And the process type, because the sections a process carries follow from it — a BATCH_JOB turned into something else would strand its batch process with no way to reach it.
type StatusService ¶
type StatusService struct {
// contains filtered or unexported fields
}
StatusService records and reads Process status history.
There is no create/update HTTP endpoint for statuses, by design: they are recorded internally rather than accepted from a client request body — an initial CREATED status when a process is submitted (see ProcessService.Create), and later transitions by whatever submits and monitors the actual job. Reads are still a service concern other code can call directly, and (via StatusController) a read-only API a client can poll for progress.
func NewStatusService ¶
func NewStatusService(db *gorm.DB, statuses *repository.StatusRepository, processes *repository.ProcessRepository) *StatusService
NewStatusService returns a status service.
func (*StatusService) Get ¶
func (s *StatusService) Get(ctx context.Context, processID, statusID string) (*dto.StatusResponse, error)
Get returns one status, scoped to the process it must belong to.
func (*StatusService) ListForProcess ¶
func (s *StatusService) ListForProcess(ctx context.Context, processID string) ([]dto.StatusResponse, error)
ListForProcess returns every recorded status of a process, oldest first.
Not owner-scoped, matching the rest of this package's reads (see ProcessService's doc comment) — the Java service carried no authorisation on process status either.
func (*StatusService) Record ¶
func (s *StatusService) Record(ctx context.Context, processID string, status model.ProcessStatusType, log *string) (*dto.StatusResponse, error)
Record appends a new status for a process, in its own transaction.
This is the entry point for a caller that is not already inside a transaction of its own — the normal case for a service in another package recording a transition it observed (e.g. a job monitor noticing a submission succeeded). It does not check authorisation: recording a status is an internal operation performed by trusted service code, never taken directly from a client request.
func (*StatusService) RecordTx ¶
func (s *StatusService) RecordTx(ctx context.Context, tx *gorm.DB, processID string, status model.ProcessStatusType, log *string) (*model.ProcessStatus, error)
RecordTx appends a new status inside an already-open transaction, so a caller that is already inside one of its own — ProcessService.Create recording the initial CREATED status alongside the process it belongs to, or another service's own multi-step write — commits or rolls back the status together with the rest of its work.
type TaskService ¶
TaskService manages one kind of task as a sub-resource of its process.
The four kinds are the same service with a different payload — scope by process, authorise against that process, order by task_order — so the rules are written once and instantiated per kind. What differs is supplied at construction: how a request is applied to a row, and what the kind is called in an error message.
Unlike the rest of this package, reads here are owner-scoped. Process and status reads are open for compatibility with clients the Java service already had; these endpoints are new, and a task carries filesystem paths and shell commands, so there is no reason to expose them more widely than the run they belong to.
func (*TaskService[T, Req]) Create ¶
func (s *TaskService[T, Req]) Create(ctx context.Context, processID string, req *Req) (*T, error)
Create adds a task to a process.
func (*TaskService[T, Req]) Delete ¶
func (s *TaskService[T, Req]) Delete(ctx context.Context, processID, taskID string) error
Delete removes a task from a process.
func (*TaskService[T, Req]) Get ¶
func (s *TaskService[T, Req]) Get(ctx context.Context, processID, taskID string) (*T, error)
Get returns one task of one process.
func (*TaskService[T, Req]) ListForProcess ¶
func (s *TaskService[T, Req]) ListForProcess(ctx context.Context, processID string) ([]T, error)
ListForProcess returns every task of one process, in execution order.
func (*TaskService[T, Req]) Update ¶
func (s *TaskService[T, Req]) Update(ctx context.Context, processID, taskID string, req *Req) (*T, error)
Update changes a task of a process.
The process it belongs to is left alone: both ids come from the path, so a task can be edited but never moved to a different run.
type TaskStatusService ¶
type TaskStatusService struct {
// contains filtered or unexported fields
}
TaskStatusService reads the status history of a process's tasks.
There is nothing to write here: the orchestration engine records task statuses as it runs each task. Reads are owner-scoped like TaskService's, since a failed task's log carries the error it failed with — remote paths and command output included.
func NewTaskStatusService ¶
func NewTaskStatusService(statuses *repository.TaskStatusRepository, processes *repository.ProcessRepository) *TaskStatusService
NewTaskStatusService returns a task status service.
func (*TaskStatusService) ListForProcess ¶
func (s *TaskStatusService) ListForProcess(ctx context.Context, processID string) ([]dto.TaskStatusResponse, error)
ListForProcess returns every status recorded for any task of a process, oldest first.
func (*TaskStatusService) ListForTask ¶
func (s *TaskStatusService) ListForTask(ctx context.Context, processID, taskID string) ([]dto.TaskStatusResponse, error)
ListForTask returns every status recorded for one task, oldest first.
The task is matched on both ids, so a task of another process yields an empty list rather than that process's history. An unknown task id is an empty list too, not a 404: the id may name a row in any of the four task tables, and a task the engine has not reached yet has no history to show.
type WorkflowService ¶
type WorkflowService struct {
// contains filtered or unexported fields
}
WorkflowService records and reads the workflows started for a process.
There is no create endpoint, by design: a workflow is recorded by the code that starts a workflow for the process, never accepted from a client request body. Reads are owner-scoped like TaskStatusService's, since a workflow id is a handle on the workflow engine's own record of the run.
func NewWorkflowService ¶
func NewWorkflowService(db *gorm.DB, workflows *repository.WorkflowRepository, processes *repository.ProcessRepository) *WorkflowService
NewWorkflowService returns a process workflow service.
func (*WorkflowService) Get ¶
func (s *WorkflowService) Get(ctx context.Context, processID, processWorkflowID string) (*dto.WorkflowResponse, error)
Get returns one process workflow by its processWorkflowId, scoped to the process it must belong to.
func (*WorkflowService) ListForProcess ¶
func (s *WorkflowService) ListForProcess(ctx context.Context, processID string) ([]dto.WorkflowResponse, error)
ListForProcess returns every workflow recorded for a process, oldest first.
func (*WorkflowService) Record ¶
func (s *WorkflowService) Record(ctx context.Context, processID, workflowID string, workflowType model.ProcessWorkflowType, status model.ProcessWorkflowStatusType) (*dto.WorkflowResponse, error)
Record records where a workflow of a process stands, in its own transaction: the first call for a workflowID creates the record, and later calls for the same one move it to the new status — RUNNING when the workflow is started, SUCCEEDED or FAILED when it finishes.
It does not check authorisation: recording a workflow is an internal operation performed by trusted service code, never taken directly from a client request.
func (*WorkflowService) RecordTx ¶
func (s *WorkflowService) RecordTx(ctx context.Context, tx *gorm.DB, processID, workflowID string, workflowType model.ProcessWorkflowType, status model.ProcessWorkflowStatusType) (*model.ProcessWorkflow, error)
RecordTx creates or updates a process workflow inside an already-open transaction, so a caller that is already inside one of its own commits or rolls back the workflow together with the rest of its work.
See WorkflowRepository.Record for what an update changes.